-import ConfigParser
+"""
+Generate settings for the Django Application.
+
+To make it easier to customize the application the settings can be
+defined in a configuration file read by ConfigParser.
+
+The options understood by this module are (with their defaults):
+
+ [frontend]
+ email_host=localhost
+ email_port=25
+ database_engine=sqlite3
+ database_name=/path/to/db
+
+ [admins]
+ #name1=email1
+ [allowed_hosts]
+ #name1=ip
+ localhost=127.0.0.1
+
+ [allowed_analysis_hosts]
+ #name1=ip
+ localhost=127.0.0.1
+
+"""
+import ConfigParser
import os
+def options_to_list(dest, section_name):
+ """
+ Load a options from section_name and store in a dictionary
+ """
+ if options.has_section(section_name):
+ for name in options.options(section_name):
+ dest.append( options.get(section_name, name) )
+
+def options_to_dict(dest, section_name):
+ """
+ Load a options from section_name and store in a dictionary
+ """
+ if options.has_section(section_name):
+ for name in options.options(section_name):
+ dest[name] = options.get(section_name, name)
+
# define your defaults here
options = ConfigParser.SafeConfigParser(
- { 'email_host': 'myerslab.stanford.edu',
+ { 'email_host': 'localhost',
'email_port': '25',
'database_engine': 'sqlite3',
'database_name':
os.path.abspath('/htsworkflow/htswfrontend/dev_fctracker.db'),
+ 'time_zone': 'America/Los_Angeles',
})
options.read([os.path.expanduser("~/.htsworkflow.ini"),
DEBUG = True
TEMPLATE_DEBUG = DEBUG
-ADMINS = (
- ('Rami Rauch', 'rrauch@stanford.edu'),
-)
+ADMINS = []
+options_to_list(ADMINS, 'admins')
MANAGERS = ADMINS
# although not all variations may be possible on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
-TIME_ZONE = 'America/Los_Angeles'
+TIME_ZONE = options.get('frontend', 'time_zone')
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
)
# Project specific settings
-ALLOWED_IPS = {"74.51.115.100":"HudsonAlpha","64.89.97.100":"HudsonAlpha","127.0.0.1":"Localhost"}
-ALLOWED_ANALYS_IPS = {"171.65.76.194":"Stanford Analysis 1","127.0.0.1":"Localhost"}
+ALLOWED_IPS={'localhost': '127.0.0.1'}
+options_to_dict(ALLOWED_IPS, 'allowed_hosts')
+
+ALLOWED_ANALYS_IPS = {'localhost': '127.0.0.1'}
+options_to_dict(ALLOWED_ANALYS_IPS, 'allowed_analysis_hosts')
#UPLOADTO_HOME = os.path.abspath('../../uploads')
#UPLOADTO_CONFIG_FILE = os.path.join(UPLOADTO_HOME, 'eland_config')
#UPLOADTO_ELAND_RESULT_PACKS = os.path.join(UPLOADTO_HOME, 'eland_results')