fixed settings
[unfold.git] / myslice / settings.py
1 #from __future__ import print_function
2 import os.path
3
4 try:
5     ROOT = os.path.realpath(os.path.dirname(__file__) + '/..')
6 except:
7     import traceback
8     traceback.print_exc()
9
10 import myslice.components as components
11 from myslice.configengine import ConfigEngine
12
13 # import djcelery
14 # djcelery.setup_loader()
15
16 ### detect if we're in a build environment
17 try:
18     import manifold
19     building=False
20 except:
21     building=True
22
23 config = ConfigEngine()
24
25 if config.myslice.debug :
26     DEBUG = True
27 else :
28     DEBUG = False
29
30 # themes
31 if config.myslice.theme :
32     theme = config.myslice.theme
33 else :
34     theme = None
35
36 # HTTPROOT
37 if config.myslice.httproot :
38     HTTPROOT = config.myslice.httproot
39 else :
40     HTTPROOT = ROOT
41
42 # DATAROOT
43 if config.myslice.httproot :
44     DATAROOT = config.myslice.dataroot
45 else :
46     DATAROOT = ROOT
47
48
49 # dec 2013 - we currently have 2 auxiliary subdirs with various utilities
50 # that we do not wish to package 
51 # * sandbox is for plugin developers
52 # * sample is for various test views
53 # for each of these, if we find a directory of that name under ROOT, it then gets
54 # inserted in INSTALLED_APPS and its urls get included (see urls.py)
55 auxiliaries = [ 'sandbox', 'sample', ]
56
57 ####################
58 ADMINS = (
59     # ('your_name', 'your_email@test.com'),
60 )
61
62 MANAGERS = ADMINS
63
64 # Mail configuration
65 #DEFAULT_FROM_EMAIL = "root@theseus.ipv6.lip6.fr"
66 #EMAIL_HOST_PASSWORD = "mypassword"
67
68 EMAIL_HOST = "localhost"
69 EMAIL_PORT = 25
70 EMAIL_USE_TLS = False
71
72 # use the email for debugging purpose
73 # turn on debugging: 
74 # python -m smtpd -n -c DebuggingServer localhost:1025
75
76 #if DEBUG:
77 #    EMAIL_HOST = 'localhost'
78 #    EMAIL_PORT = 1025
79 #    EMAIL_HOST_USER = ''
80 #    EMAIL_HOST_PASSWORD = ''
81 #    EMAIL_USE_TLS = False
82 #    DEFAULT_FROM_EMAIL = 'testing@example.com'
83
84 if config.database : 
85     DATABASES = {
86         'default': {
87             'ENGINE'    : 'django.db.backends.%s' % config.database.engine,
88             'USER'      : config.database.user or '',
89             'PASSWORD'  : config.database.password or '',
90             'HOST'      : config.database.host or '',
91             'PORT'      : config.database.port or '',
92         }
93     }
94     if config.database.engine == 'sqlite3' :
95         DATABASES['default']['NAME'] = os.path.join(DATAROOT,'%s.sqlite3' % config.database.name)
96     else :
97         DATABASES['default']['NAME'] = config.database.name
98 else :
99     # default database is sqlite
100     DATABASES = {
101         'default': {
102             'ENGINE'    : 'django.db.backends.sqlite3',
103             'NAME'      : os.path.join(DATAROOT,'myslice.sqlite3'),
104             'USER'      : '',
105             'PASSWORD'  : '',
106             'HOST'      : '',
107             'PORT'      : '',
108         }
109     }
110 print DATABASES
111 # Local time zone for this installation. Choices can be found here:
112 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
113 # although not all choices may be available on all operating systems.
114 # In a Windows environment this must be set to your system time zone.
115 TIME_ZONE = 'Europe/Paris'
116
117 # Language code for this installation. All choices can be found here:
118 # http://www.i18nguy.com/unicode/language-identifiers.html
119 LANGUAGE_CODE = 'en-us'
120
121 SITE_ID = 1
122
123 # If you set this to False, Django will make some optimizations so as not
124 # to load the internationalization machinery.
125 USE_I18N = True
126
127 # If you set this to False, Django will not format dates, numbers and
128 # calendars according to the current locale.
129 USE_L10N = True
130
131 # If you set this to False, Django will not use timezone-aware datetimes.
132 USE_TZ = True
133
134 # Absolute filesystem path to the directory that will hold user-uploaded files.
135 # Example: "/home/media/media.lawrence.com/media/"
136 MEDIA_ROOT = ''
137
138 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
139 # trailing slash.
140 # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
141 MEDIA_URL = ''
142
143 # Absolute path to the directory static files should be collected to.
144 # Don't put anything in this directory yourself; store your static files
145 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
146 # Example: "/home/media/media.lawrence.com/static/"
147 STATIC_ROOT = os.path.join(HTTPROOT,'static')
148
149 # URL prefix for static files.
150 # Example: "http://media.lawrence.com/static/"
151 STATIC_URL = '/static/'
152
153 # Additional locations of static files
154 STATICFILES_DIRS = (
155     # Put strings here, like "/home/html/static" or "C:/www/django/static".
156     # Always use forward slashes, even on Windows.
157     # Don't forget to use absolute paths, not relative paths.
158     # Thierry : we do not need to detail the contents 
159     # of our 'apps' since they're mentioned in INSTALLED_APPS
160 )
161
162 # Needed by PluginFinder
163 PLUGIN_DIR = os.path.join(ROOT,'plugins')
164 # ThirdPartyFinder
165 THIRDPARTY_DIR = os.path.join(ROOT, 'third-party')
166
167 # List of finder classes that know how to find static files in
168 # various locations.
169 STATICFILES_FINDERS = (
170 # Thierry : no need for this one    
171 #    'django.contrib.staticfiles.finders.FileSystemFinder',
172     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
173     'unfold.collectstatic.PluginFinder',
174     'unfold.collectstatic.ThirdPartyFinder',
175 ###    'django.contrib.staticfiles.finders.DefaultStorageFinder',
176 )
177
178 #TEMPLATE_CONTEXT_PROCESSORS = (
179 #    'django.contrib.auth.context_processors.auth',
180 #    'django.core.context_processors.debug',
181 #    'django.core.context_processors.i18n',
182 #    'django.core.context_processors.media',
183 #    'django.core.context_processors.static',
184 #    'django.core.context_processors.request',
185 #    'django.contrib.messages.context_processors.messages',
186 #)
187
188 # Make this unique, and don't share it with anybody.
189 SECRET_KEY = 't%n(3h)&r^n8(+8)(sp29t^$c2#t(m3)e2!02l8w1#36tl#t27'
190
191 # List of callables that know how to import templates from various sources.
192 TEMPLATE_LOADERS = (
193     'django.template.loaders.filesystem.Loader',
194     'django.template.loaders.app_directories.Loader',
195 #     'django.template.loaders.eggs.Loader',
196 )
197
198 MIDDLEWARE_CLASSES = (
199     'django.middleware.common.CommonMiddleware',
200     'django.contrib.sessions.middleware.SessionMiddleware',
201     'django.middleware.csrf.CsrfViewMiddleware',
202     'django.contrib.auth.middleware.AuthenticationMiddleware',
203     'django.contrib.messages.middleware.MessageMiddleware',
204     # Uncomment the next line for simple clickjacking protection:
205     # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
206 )
207
208 ROOT_URLCONF = 'myslice.urls'
209
210 # Python dotted path to the WSGI application used by Django's runserver.
211 WSGI_APPLICATION = 'unfold.wsgi.application'
212
213 TEMPLATE_DIRS = []
214 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
215 # Always use forward slashes, even on Windows.
216 # Don't forget to use absolute paths, not relative paths.
217 if theme is not None:
218     TEMPLATE_DIRS.append( os.path.join(HTTPROOT,"portal/templates", theme) )
219 TEMPLATE_DIRS.append( os.path.join(HTTPROOT,"portal/templates") )
220 TEMPLATE_DIRS.append( os.path.join(HTTPROOT,"templates") )
221
222 INSTALLED_APPS = [ 
223     'django.contrib.auth',
224     'django.contrib.contenttypes',
225     'django.contrib.sessions',
226     'django.contrib.sites',
227     'django.contrib.messages',
228     'django.contrib.staticfiles',
229     # handling the {% insert %} and {% container %} tags
230     # see details in devel/django-insert-above-1.0-4
231     'insert_above',
232     # our django project
233     'myslice',
234     # the core of the UI
235     'auth', 
236     'manifoldapi',
237     'unfold',
238     # plugins
239     'plugins',
240     # views - more or less stable 
241     'ui',
242     # managing database migrations
243     'south', 
244     # Uncomment the next line to enable the admin:
245      'django.contrib.admin',
246         # FORGE Plugin app
247 #       'djcelery',
248     # Uncomment the next line to enable admin documentation:
249     # 'django.contrib.admindocs',
250     'portal',
251 ]
252 # this app won't load in a build environment
253 if not building: INSTALLED_APPS.append ('rest')
254
255 for component in components.list() :
256     INSTALLED_APPS.append(component)
257
258 BROKER_URL = "amqp://myslice:myslice@localhost:5672/myslice"
259
260 for aux in auxiliaries:
261     if os.path.isdir(os.path.join(ROOT,aux)): 
262         print("Using devel auxiliary",aux)
263         INSTALLED_APPS.append(aux)
264
265 ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
266
267 # A sample logging configuration. The only tangible logging
268 # performed by this configuration is to send an email to
269 # the site admins on every HTTP 500 error when DEBUG=False.
270 # See http://docs.djangoproject.com/en/dev/topics/logging for
271 # more details on how to customize your logging configuration.
272 LOGGING = {
273     'version': 1,
274     'disable_existing_loggers': False,
275     'filters': {
276         'require_debug_false': {
277             '()': 'django.utils.log.RequireDebugFalse'
278         }
279     },
280     'handlers': {
281         'mail_admins': {
282             'level': 'ERROR',
283             'filters': ['require_debug_false'],
284             'class': 'django.utils.log.AdminEmailHandler',
285         }
286     },
287     'loggers': {
288         'django.request': {
289             'handlers': ['mail_admins'],
290             'level': 'ERROR',
291             'propagate': True,
292         },
293     }
294 }
295
296 AUTHENTICATION_BACKENDS = ('auth.manifoldbackend.ManifoldBackend',
297                            'django.contrib.auth.backends.ModelBackend')
298
299 ### the view to redirect malformed (i.e. with a wrong CSRF) incoming requests
300 # without this setting django will return a 403 forbidden error, which is fine
301 # if you need to see the error message then use this setting
302 CSRF_FAILURE_VIEW = 'manifoldapi.manifoldproxy.csrf_failure'
303
304 #################### for insert_above
305 #IA_JS_FORMAT = "<script type='text/javascript' src='{URL}' />"
306 # put stuff under static/
307 # IA_MEDIA_PREFIX = '/code/'
308
309 ####SLA#####
310
311 SLA_MANAGER_URL = "http://157.193.215.125:4001/sla-collector/sla"
312 #SLA_MANAGER_URL = "http://172.24.76.28:8000/sla"
313 SLA_MANAGER_USER = "portal"
314 SLA_MANAGER_PASSWORD = "password"