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