apache: apache config file fixed to run on apache server
[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/myslice-f4f"
46 # the place to store local data, like e.g. the sqlite db
47 DATAROOT="/var/unfold"
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
203 TEMPLATE_DIRS = [ ]
204 # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
205 # Always use forward slashes, even on Windows.
206 # Don't forget to use absolute paths, not relative paths.
207 if theme is not None:
208     TEMPLATE_DIRS.append ( os.path.join(HTTPROOT,"portal/templates", theme))
209 TEMPLATE_DIRS.append     ( os.path.join(HTTPROOT,"portal/templates"))
210 TEMPLATE_DIRS.append     (  os.path.join(HTTPROOT,"templates"))
211
212 INSTALLED_APPS = [ 
213     'django.contrib.auth',
214     'django.contrib.contenttypes',
215     'django.contrib.sessions',
216     'django.contrib.sites',
217     'django.contrib.messages',
218     'django.contrib.staticfiles',
219     # handling the {% insert %} and {% container %} tags
220     # see details in devel/django-insert-above-1.0-4
221     'insert_above',
222     # our django project
223     'myslice',
224     # the core of the UI
225     'auth', 
226     'manifoldapi',
227     'unfold',
228     # plugins
229     'plugins',
230     # views - more or less stable 
231     'ui',
232     # managing database migrations
233     'south', 
234     # Uncomment the next line to enable the admin:
235      'django.contrib.admin',
236     # Uncomment the next line to enable admin documentation:
237     # 'django.contrib.admindocs',
238     'portal',
239 ]
240 # this app won't load in a build environment
241 if not building: INSTALLED_APPS.append ('rest')
242
243 for aux in auxiliaries:
244     if os.path.isdir(os.path.join(ROOT,aux)): 
245         print "Using devel auxiliary",aux
246         INSTALLED_APPS.append(aux)
247
248 ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
249
250 # A sample logging configuration. The only tangible logging
251 # performed by this configuration is to send an email to
252 # the site admins on every HTTP 500 error when DEBUG=False.
253 # See http://docs.djangoproject.com/en/dev/topics/logging for
254 # more details on how to customize your logging configuration.
255 LOGGING = {
256     'version': 1,
257     'disable_existing_loggers': False,
258     'filters': {
259         'require_debug_false': {
260             '()': 'django.utils.log.RequireDebugFalse'
261         }
262     },
263     'handlers': {
264         'mail_admins': {
265             'level': 'ERROR',
266             'filters': ['require_debug_false'],
267             'class': 'django.utils.log.AdminEmailHandler',
268         }
269     },
270     'loggers': {
271         'django.request': {
272             'handlers': ['mail_admins'],
273             'level': 'ERROR',
274             'propagate': True,
275         },
276     }
277 }
278
279 AUTHENTICATION_BACKENDS = ( 'auth.manifoldbackend.ManifoldBackend','django.contrib.auth.backends.ModelBackend' )
280
281 ### the view to redirect malformed (i.e. with a wrong CSRF) incoming requests
282 # without this setting django will return a 403 forbidden error, which is fine
283 # if you need to see the error message then use this setting
284 CSRF_FAILURE_VIEW = 'manifoldapi.manifoldproxy.csrf_failure'
285
286 #################### for insert_above
287 #IA_JS_FORMAT = "<script type='text/javascript' src='{URL}' />"
288 # put stuff under static/
289 # IA_MEDIA_PREFIX = '/code/'