Config -> ConfigEngine
[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 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
185 TEMPLATE_DIRS = (
186     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
187     # Always use forward slashes, even on Windows.
188     # Don't forget to use absolute paths, not relative paths.
189     os.path.join(HTTPROOT,"templates"),
190 )
191
192 INSTALLED_APPS = [
193     'django.contrib.auth',
194     'django.contrib.contenttypes',
195     'django.contrib.sessions',
196     'django.contrib.sites',
197     'django.contrib.messages',
198     'django.contrib.staticfiles',
199     # handling the {% insert %} and {% container %} tags
200     # see details in devel/django-insert-above-1.0-4
201     'insert_above',
202     # our django project
203     'myslice',
204     # the core of the UI
205     'auth', 'manifold', 'unfold',
206     # plugins
207     'plugins',
208     # views - more or less stable 
209     'ui',
210     # managing database migrations
211     'south', 
212     # Uncomment the next line to enable the admin:
213      'django.contrib.admin',
214     # Uncomment the next line to enable admin documentation:
215     # 'django.contrib.admindocs',
216     'portal',
217 ]
218 for aux in auxiliaries:
219     if os.path.isdir(os.path.join(ROOT,aux)): 
220         print "Using devel auxiliary",aux
221         INSTALLED_APPS.append(aux)
222
223 ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
224
225 # A sample logging configuration. The only tangible logging
226 # performed by this configuration is to send an email to
227 # the site admins on every HTTP 500 error when DEBUG=False.
228 # See http://docs.djangoproject.com/en/dev/topics/logging for
229 # more details on how to customize your logging configuration.
230 LOGGING = {
231     'version': 1,
232     'disable_existing_loggers': False,
233     'filters': {
234         'require_debug_false': {
235             '()': 'django.utils.log.RequireDebugFalse'
236         }
237     },
238     'handlers': {
239         'mail_admins': {
240             'level': 'ERROR',
241             'filters': ['require_debug_false'],
242             'class': 'django.utils.log.AdminEmailHandler',
243         }
244     },
245     'loggers': {
246         'django.request': {
247             'handlers': ['mail_admins'],
248             'level': 'ERROR',
249             'propagate': True,
250         },
251     }
252 }
253
254 AUTHENTICATION_BACKENDS = ( 'auth.manifoldbackend.ManifoldBackend','django.contrib.auth.backends.ModelBackend' )
255
256 ### the view to redirect malformed (i.e. with a wrong CSRF) incoming requests
257 # without this setting django will return a 403 forbidden error, which is fine
258 # if you need to see the error message then use this setting
259 CSRF_FAILURE_VIEW = 'manifold.manifoldproxy.csrf_failure'
260
261 #################### for insert_above
262 #IA_JS_FORMAT = "<script type='text/javascript' src='{URL}' />"
263 # put stuff under static/
264 # IA_MEDIA_PREFIX = '/code/'