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