2 Generate settings for the Django Application.
4 To make it easier to customize the application the settings can be
5 defined in a configuration file read by ConfigParser.
7 The options understood by this module are (with their defaults):
12 database_engine=sqlite3
13 database_name=/path/to/db
22 [allowed_analysis_hosts]
32 from django.conf import global_settings
34 HTSWORKFLOW_ROOT = os.path.abspath(os.path.split(htsworkflow.__file__)[0])
37 __docformat__ = "restructuredtext en"
39 def options_to_list(options, dest, section_name, option_name):
41 Load a options from section_name and store in a dictionary
43 if options.has_option(section_name, option_name):
44 opt = options.get(section_name, option_name)
45 dest.extend( shlex.split(opt) )
47 def options_to_dict(dest, section_name):
49 Load a options from section_name and store in a dictionary
51 if options.has_section(section_name):
52 for name in options.options(section_name):
53 dest[name] = options.get(section_name, name)
55 # define your defaults here
56 options = ConfigParser.SafeConfigParser(
57 { 'email_host': 'localhost',
59 'database_engine': 'sqlite3',
61 os.path.join(HTSWORKFLOW_ROOT, '..', 'fctracker.db'),
62 'time_zone': 'America/Los_Angeles',
64 'link_flowcell_storage_device_url': "http://localhost:8000/inventory/lts/link/",
65 'printer1_host': '127.0.0.1',
66 'printer1_port': '9100',
67 'printer2_host': '127.0.0.1',
68 'printer2_port': '9100',
71 options.read([os.path.expanduser("~/.htsworkflow.ini"),
72 '/etc/htsworkflow.ini',])
74 # OptionParser will use the dictionary passed into the config parser as
75 # 'Default' values in any section. However it still needs an empty section
76 # to exist in order to retrieve anything.
77 if not options.has_section('frontend'):
78 options.add_section('frontend')
79 if not options.has_section('bcprinter'):
80 options.add_section('bcprinter')
83 # Django settings for elandifier project.
86 TEMPLATE_DEBUG = DEBUG
89 options_to_list(options, ADMINS, 'frontend', 'admins')
92 options_to_list(options, MANAGERS, 'frontend', 'managers')
94 DEFAULT_PM=int(options.get('frontend', 'default_pm'))
96 AUTHENTICATION_BACKENDS = (
97 'htsworkflow.frontend.samples.auth_backend.HTSUserModelBackend', )
98 CUSTOM_USER_MODEL = 'samples.HTSUser'
100 EMAIL_HOST = options.get('frontend', 'email_host')
101 EMAIL_PORT = int(options.get('frontend', 'email_port'))
103 if options.has_option('frontend', 'notification_sender'):
104 NOTIFICATION_SENDER = options.get('frontend', 'notification_sender')
106 NOTIFICATION_SENDER = "noreply@example.com"
107 NOTIFICATION_BCC = []
108 options_to_list(options, NOTIFICATION_BCC, 'frontend', 'notification_bcc')
110 database_section = options.get('frontend', 'database', 'database')
112 if not options.has_section(database_section):
113 raise ConfigParser.NoSectionError(
114 "No database=<database_section_name> defined")
116 # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
117 DATABASE_ENGINE = options.get(database_section, 'engine')
118 DATABASE_NAME = options.get(database_section, 'name')
119 if options.has_option(database_section, 'user'):
120 DATABASE_USER = options.get(database_section, 'user')
121 if options.has_option(database_section, 'host'):
122 DATABASE_HOST = options.get(database_section, 'host')
123 if options.has_option(database_section, 'port'):
124 DATABASE_PORT = options.get(database_section, 'port')
126 if options.has_option(database_section, 'password_file'):
127 password_file = options.get(database_section, 'password_file')
128 DATABASE_PASSWORD = open(password_file,'r').readline()
129 elif options.has_option(database_section, 'password'):
130 DATABASE_PASSWORD = options.get(database_section, 'password')
132 # Local time zone for this installation. Choices can be found here:
133 # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
134 # although not all variations may be possible on all operating systems.
135 # If running in a Windows environment this must be set to the same as your
137 TIME_ZONE = options.get('frontend', 'time_zone')
139 # Language code for this installation. All choices can be found here:
140 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
141 # http://blogs.law.harvard.edu/tech/stories/storyReader$15
142 LANGUAGE_CODE = 'en-us'
146 # If you set this to False, Django will make some optimizations so as not
147 # to load the internationalization machinery.
150 # Absolute path to the directory that holds media.
151 # Example: "/home/media/media.lawrence.com/"
152 MEDIA_ROOT = os.path.join(HTSWORKFLOW_ROOT, 'frontend', 'static', '')
154 # URL that handles the media served from MEDIA_ROOT.
155 # Example: "http://media.lawrence.com"
156 MEDIA_URL = '/static/'
158 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
160 # Examples: "http://foo.com/media/", "/media/".
161 ADMIN_MEDIA_PREFIX = '/media/'
163 # Make this unique, and don't share it with anybody.
164 SECRET_KEY = '(ekv^=gf(j9f(x25@a7r+8)hqlz%&_1!tw^75l%^041#vi=@4n'
166 # some of our urls need an api key
167 DEFAULT_API_KEY = 'n7HsXGHIi0vp9j5u4TIRJyqAlXYc4wrH'
169 # List of callables that know how to import templates from various sources.
171 'django.template.loaders.filesystem.load_template_source',
172 'django.template.loaders.app_directories.load_template_source',
173 # 'django.template.loaders.eggs.load_template_source',
176 MIDDLEWARE_CLASSES = (
177 'django.contrib.csrf.middleware.CsrfMiddleware',
178 'django.middleware.common.CommonMiddleware',
179 'django.contrib.sessions.middleware.SessionMiddleware',
180 'django.contrib.auth.middleware.AuthenticationMiddleware',
181 'django.middleware.doc.XViewMiddleware',
184 TEMPLATE_CONTEXT_PROCESSORS = global_settings.TEMPLATE_CONTEXT_PROCESSORS + (
185 'htsworkflow.frontend.thispage.thispage',
187 ROOT_URLCONF = 'htsworkflow.frontend.urls'
190 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
191 # Always use forward slashes, even on Windows.
192 # Don't forget to use absolute paths, not relative paths.
193 '/usr/share/python-support/python-django/django/contrib/admin/templates',
194 #'/usr/lib/pymodules/python2.6/django/contrib/admin/templates/',
195 os.path.join(HTSWORKFLOW_ROOT, 'frontend', 'templates'),
196 os.path.join(HTSWORKFLOW_ROOT, 'templates'),
200 'django.contrib.admin',
201 'django.contrib.auth',
202 'django.contrib.contenttypes',
203 'django.contrib.humanize',
204 'django.contrib.sessions',
205 'django.contrib.sites',
206 'htsworkflow.frontend.eland_config',
207 'htsworkflow.frontend.samples',
208 # modules from htsworkflow branch
209 'htsworkflow.frontend.experiments',
210 'htsworkflow.frontend.analysis',
211 'htsworkflow.frontend.reports',
212 'htsworkflow.frontend.inventory',
213 'htsworkflow.frontend.bcmagic',
214 'htsworkflow.frontend.labels',
215 'django.contrib.databrowse',
218 # Project specific settings
220 ALLOWED_IPS={'127.0.0.1': '127.0.0.1'}
221 options_to_dict(ALLOWED_IPS, 'allowed_hosts')
223 ALLOWED_ANALYS_IPS = {'127.0.0.1': '127.0.0.1'}
224 options_to_dict(ALLOWED_ANALYS_IPS, 'allowed_analysis_hosts')
225 #UPLOADTO_HOME = os.path.abspath('../../uploads')
226 #UPLOADTO_CONFIG_FILE = os.path.join(UPLOADTO_HOME, 'eland_config')
227 #UPLOADTO_ELAND_RESULT_PACKS = os.path.join(UPLOADTO_HOME, 'eland_results')
228 #UPLOADTO_BED_PACKS = os.path.join(UPLOADTO_HOME, 'bed_packs')
229 # Where "results_dir" means directory with all the flowcells
230 if options.has_option('frontend', 'results_dir'):
231 RESULT_HOME_DIR=os.path.expanduser(options.get('frontend', 'results_dir'))
233 RESULT_HOME_DIR='/tmp'
235 LINK_FLOWCELL_STORAGE_DEVICE_URL = options.get('frontend', 'link_flowcell_storage_device_url')
236 # PORT 9100 is default for Zebra tabletop/desktop printers
237 # PORT 6101 is default for Zebra mobile printers
238 BCPRINTER_PRINTER1_HOST = options.get('bcprinter', 'printer1_host')
239 BCPRINTER_PRINTER1_PORT = int(options.get('bcprinter', 'printer1_port'))
240 BCPRINTER_PRINTER2_HOST = options.get('bcprinter', 'printer2_host')
241 BCPRINTER_PRINTER2_PORT = int(options.get('bcprinter', 'printer2_port'))