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]
33 HTSWORKFLOW_ROOT = os.path.abspath(os.path.split(htsworkflow.__file__)[0])
36 __docformat__ = "restructuredtext en"
38 def options_to_list(options, dest, section_name, option_name):
40 Load a options from section_name and store in a dictionary
42 if options.has_option(section_name, option_name):
43 opt = options.get(section_name, option_name)
44 dest.extend( shlex.split(opt) )
46 def options_to_dict(dest, section_name):
48 Load a options from section_name and store in a dictionary
50 if options.has_section(section_name):
51 for name in options.options(section_name):
52 dest[name] = options.get(section_name, name)
54 # define your defaults here
55 options = ConfigParser.SafeConfigParser(
56 { 'email_host': 'localhost',
58 'database_engine': 'sqlite3',
60 os.path.join(HTSWORKFLOW_ROOT, '..', 'fctracker.db'),
61 'time_zone': 'America/Los_Angeles',
63 'link_flowcell_storage_device_url': "http://localhost:8000/inventory/lts/link/",
64 'printer1_host': '127.0.0.1',
65 'printer1_port': '9100',
66 'printer2_host': '127.0.0.1',
67 'printer2_port': '9100',
70 options.read([os.path.expanduser("~/.htsworkflow.ini"),
71 '/etc/htsworkflow.ini',])
73 # OptionParser will use the dictionary passed into the config parser as
74 # 'Default' values in any section. However it still needs an empty section
75 # to exist in order to retrieve anything.
76 if not options.has_section('frontend'):
77 options.add_section('frontend')
78 if not options.has_section('bcprinter'):
79 options.add_section('bcprinter')
82 # Django settings for elandifier project.
85 TEMPLATE_DEBUG = DEBUG
88 options_to_list(options, ADMINS, 'frontend', 'admins')
91 options_to_list(options, MANAGERS, 'frontend', 'managers')
93 DEFAULT_PM=int(options.get('frontend', 'default_pm'))
95 AUTHENTICATION_BACKENDS = (
96 'htsworkflow.frontend.samples.auth_backend.HTSUserModelBackend', )
97 CUSTOM_USER_MODEL = 'samples.HTSUser'
99 EMAIL_HOST = options.get('frontend', 'email_host')
100 EMAIL_PORT = int(options.get('frontend', 'email_port'))
102 if options.has_option('frontend', 'notification_sender'):
103 NOTIFICATION_SENDER = options.get('frontend', 'notification_sender')
105 NOTIFICATION_SENDER = "noreply@example.com"
106 NOTIFICATION_BCC = []
107 options_to_list(options, NOTIFICATION_BCC, 'frontend', 'notification_bcc')
109 database_section = options.get('frontend', 'database', 'database')
111 if not options.has_section(database_section):
112 raise ConfigParser.NoSectionError(
113 "No database=<database_section_name> defined")
115 # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
116 DATABASE_ENGINE = options.get(database_section, 'engine')
117 DATABASE_NAME = options.get(database_section, 'name')
118 if options.has_option(database_section, 'user'):
119 DATABASE_USER = options.get(database_section, 'user')
120 if options.has_option(database_section, 'host'):
121 DATABASE_HOST = options.get(database_section, 'host')
122 if options.has_option(database_section, 'port'):
123 DATABASE_PORT = options.get(database_section, 'port')
125 if options.has_option(database_section, 'password_file'):
126 password_file = options.get(database_section, 'password_file')
127 DATABASE_PASSWORD = open(password_file,'r').readline()
128 elif options.has_option(database_section, 'password'):
129 DATABASE_PASSWORD = options.get(database_section, 'password')
131 # Local time zone for this installation. Choices can be found here:
132 # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
133 # although not all variations may be possible on all operating systems.
134 # If running in a Windows environment this must be set to the same as your
136 TIME_ZONE = options.get('frontend', 'time_zone')
138 # Language code for this installation. All choices can be found here:
139 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
140 # http://blogs.law.harvard.edu/tech/stories/storyReader$15
141 LANGUAGE_CODE = 'en-us'
145 # If you set this to False, Django will make some optimizations so as not
146 # to load the internationalization machinery.
149 # Absolute path to the directory that holds media.
150 # Example: "/home/media/media.lawrence.com/"
151 MEDIA_ROOT = os.path.join(HTSWORKFLOW_ROOT, 'frontend', 'static', '')
153 # URL that handles the media served from MEDIA_ROOT.
154 # Example: "http://media.lawrence.com"
155 MEDIA_URL = '/static/'
157 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
159 # Examples: "http://foo.com/media/", "/media/".
160 ADMIN_MEDIA_PREFIX = '/media/'
162 # Make this unique, and don't share it with anybody.
163 SECRET_KEY = '(ekv^=gf(j9f(x25@a7r+8)hqlz%&_1!tw^75l%^041#vi=@4n'
165 # some of our urls need an api key
166 DEFAULT_API_KEY = 'n7HsXGHIi0vp9j5u4TIRJyqAlXYc4wrH'
168 # List of callables that know how to import templates from various sources.
170 'django.template.loaders.filesystem.load_template_source',
171 'django.template.loaders.app_directories.load_template_source',
172 # 'django.template.loaders.eggs.load_template_source',
175 MIDDLEWARE_CLASSES = [
176 'django.middleware.common.CommonMiddleware',
177 'django.contrib.sessions.middleware.SessionMiddleware',
178 'django.contrib.auth.middleware.AuthenticationMiddleware',
179 'django.middleware.doc.XViewMiddleware',
181 # be forgiving for django 1.1 which doesn't have csrf protection
182 # TODO remove this when we upgrade to django 1.2
183 if django.VERSION[0] == 1 and django.VERSION[1] > 1:
184 MIDDLEWARE_CLASSES.insert(0, 'django.middleware.csrf.CsrfViewMiddleware')
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'),
199 'django.contrib.admin',
200 'django.contrib.auth',
201 'django.contrib.contenttypes',
202 'django.contrib.humanize',
203 'django.contrib.sessions',
204 'django.contrib.sites',
205 'htsworkflow.frontend.eland_config',
206 'htsworkflow.frontend.samples',
207 # modules from htsworkflow branch
208 'htsworkflow.frontend.experiments',
209 'htsworkflow.frontend.analysis',
210 'htsworkflow.frontend.reports',
211 'htsworkflow.frontend.inventory',
212 'htsworkflow.frontend.bcmagic',
213 'htsworkflow.frontend.labels',
214 'django.contrib.databrowse',
217 # Project specific settings
219 ALLOWED_IPS={'127.0.0.1': '127.0.0.1'}
220 options_to_dict(ALLOWED_IPS, 'allowed_hosts')
222 ALLOWED_ANALYS_IPS = {'127.0.0.1': '127.0.0.1'}
223 options_to_dict(ALLOWED_ANALYS_IPS, 'allowed_analysis_hosts')
224 #UPLOADTO_HOME = os.path.abspath('../../uploads')
225 #UPLOADTO_CONFIG_FILE = os.path.join(UPLOADTO_HOME, 'eland_config')
226 #UPLOADTO_ELAND_RESULT_PACKS = os.path.join(UPLOADTO_HOME, 'eland_results')
227 #UPLOADTO_BED_PACKS = os.path.join(UPLOADTO_HOME, 'bed_packs')
228 # Where "results_dir" means directory with all the flowcells
229 if options.has_option('frontend', 'results_dir'):
230 RESULT_HOME_DIR=os.path.expanduser(options.get('frontend', 'results_dir'))
232 RESULT_HOME_DIR='/tmp'
234 LINK_FLOWCELL_STORAGE_DEVICE_URL = options.get('frontend', 'link_flowcell_storage_device_url')
235 # PORT 9100 is default for Zebra tabletop/desktop printers
236 # PORT 6101 is default for Zebra mobile printers
237 BCPRINTER_PRINTER1_HOST = options.get('bcprinter', 'printer1_host')
238 BCPRINTER_PRINTER1_PORT = int(options.get('bcprinter', 'printer1_port'))
239 BCPRINTER_PRINTER2_HOST = options.get('bcprinter', 'printer2_host')
240 BCPRINTER_PRINTER2_PORT = int(options.get('bcprinter', 'printer2_port'))