Merged much of the stanford htsworkflow frontend into trunk.
[htsworkflow.git] / htsworkflow / frontend / settings.py
1 """
2 Generate settings for the Django Application.
3
4 To make it easier to customize the application the settings can be 
5 defined in a configuration file read by ConfigParser.
6
7 The options understood by this module are (with their defaults):
8
9   [frontend]
10   email_host=localhost
11   email_port=25
12   database_engine=sqlite3
13   database_name=/path/to/db
14
15   [admins]
16   #name1=email1
17
18   [allowed_hosts]
19   #name1=ip
20   localhost=127.0.0.1
21   
22   [allowed_analysis_hosts]
23   #name1=ip
24   localhost=127.0.0.1
25
26 """
27 import ConfigParser
28 import os
29
30 def options_to_list(dest, section_name):
31   """
32   Load a options from section_name and store in a dictionary
33   """
34   if options.has_section(section_name):
35     for name in options.options(section_name):
36       dest.append( options.get(section_name, name) )
37       
38 def options_to_dict(dest, section_name):
39   """
40   Load a options from section_name and store in a dictionary
41   """
42   if options.has_section(section_name):
43     for name in options.options(section_name):
44       dest[name] = options.get(section_name, name)
45
46 # define your defaults here
47 options = ConfigParser.SafeConfigParser(
48            { 'email_host': 'localhost',
49              'email_port': '25', 
50              'database_engine': 'sqlite3',
51              'database_name': 
52                os.path.abspath('/htsworkflow/htswfrontend/dev_fctracker.db'),
53              'time_zone': 'America/Los_Angeles',
54            })
55
56 options.read([os.path.expanduser("~/.htsworkflow.ini"),
57               '/etc/htsworkflow.ini',])
58
59 # Django settings for elandifier project.
60
61 DEBUG = True
62 TEMPLATE_DEBUG = DEBUG
63
64 ADMINS = []
65 options_to_list(ADMINS, 'admins')
66
67 MANAGERS = ADMINS
68
69 EMAIL_HOST = options.get('frontend', 'email_host')
70 EMAIL_PORT = int(options.get('frontend', 'email_port'))
71
72 # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
73 DATABASE_ENGINE = options.get('frontend', 'database_engine')
74
75 # Or path to database file if using sqlite3.
76 DATABASE_NAME = options.get('frontend', 'database_name' )
77 DATABASE_USER = ''             # Not used with sqlite3.
78 DATABASE_PASSWORD = ''         # Not used with sqlite3.
79 DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
80 DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
81
82 # Local time zone for this installation. Choices can be found here:
83 # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
84 # although not all variations may be possible on all operating systems.
85 # If running in a Windows environment this must be set to the same as your
86 # system time zone.
87 TIME_ZONE = options.get('frontend', 'time_zone')
88
89 # Language code for this installation. All choices can be found here:
90 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
91 # http://blogs.law.harvard.edu/tech/stories/storyReader$15
92 LANGUAGE_CODE = 'en-us'
93
94 SITE_ID = 1
95
96 # If you set this to False, Django will make some optimizations so as not
97 # to load the internationalization machinery.
98 USE_I18N = True
99
100 # Absolute path to the directory that holds media.
101 # Example: "/home/media/media.lawrence.com/"
102 MEDIA_ROOT = ''
103
104 # URL that handles the media served from MEDIA_ROOT.
105 # Example: "http://media.lawrence.com"
106 MEDIA_URL = ''
107
108 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
109 # trailing slash.
110 # Examples: "http://foo.com/media/", "/media/".
111 ADMIN_MEDIA_PREFIX = '/media/'
112
113 # Make this unique, and don't share it with anybody.
114 SECRET_KEY = '(ekv^=gf(j9f(x25@a7r+8)hqlz%&_1!tw^75l%^041#vi=@4n'
115
116 # List of callables that know how to import templates from various sources.
117 TEMPLATE_LOADERS = (
118     'django.template.loaders.filesystem.load_template_source',
119     'django.template.loaders.app_directories.load_template_source',
120 #     'django.template.loaders.eggs.load_template_source',
121 )
122
123 MIDDLEWARE_CLASSES = (
124     'django.middleware.common.CommonMiddleware',
125     'django.contrib.sessions.middleware.SessionMiddleware',
126     'django.contrib.auth.middleware.AuthenticationMiddleware',
127     'django.middleware.doc.XViewMiddleware',
128 )
129
130 ROOT_URLCONF = 'htsworkflow.frontend.urls'
131
132 TEMPLATE_DIRS = (
133     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
134     # Always use forward slashes, even on Windows.
135     # Don't forget to use absolute paths, not relative paths.
136     os.path.join(os.path.split(__file__)[0], 'templates'),
137 )
138
139 INSTALLED_APPS = (
140     'django.contrib.admin',
141     'django.contrib.auth',
142     'django.contrib.contenttypes',
143     'django.contrib.sessions',
144     'django.contrib.sites',
145     'htsworkflow.frontend.eland_config',
146     'htsworkflow.frontend.samples',
147     # modules from htsworkflow branch
148     'htsworkflow.frontend.experiments',
149     'htsworkflow.frontend.analysis', 
150     'htsworkflow.frontend.reports',
151     'django.contrib.databrowse',
152 )
153
154 # Project specific settings
155
156 ALLOWED_IPS={'localhost': '127.0.0.1'}
157 options_to_dict(ALLOWED_IPS, 'allowed_hosts')
158
159 ALLOWED_ANALYS_IPS = {'localhost': '127.0.0.1'}
160 options_to_dict(ALLOWED_ANALYS_IPS, 'allowed_analysis_hosts')
161 #UPLOADTO_HOME = os.path.abspath('../../uploads')
162 #UPLOADTO_CONFIG_FILE = os.path.join(UPLOADTO_HOME, 'eland_config')
163 #UPLOADTO_ELAND_RESULT_PACKS = os.path.join(UPLOADTO_HOME, 'eland_results')
164 #UPLOADTO_BED_PACKS = os.path.join(UPLOADTO_HOME, 'bed_packs')