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