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