70b4a87a6063ef619769938d6559cb1093a9b528
[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 DATABASES = {
61     'default': {
62         'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
63         'NAME': os.path.join(DATAROOT,'unfold.sqlite3'), # Or path to database file if using sqlite3.
64         'USER': '',                      # Not used with sqlite3.
65         'PASSWORD': '',                  # Not used with sqlite3.
66         'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
67         'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
68     }
69 }
70
71 # Local time zone for this installation. Choices can be found here:
72 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
73 # although not all choices may be available on all operating systems.
74 # In a Windows environment this must be set to your system time zone.
75 TIME_ZONE = 'Europe/Paris'
76
77 # Language code for this installation. All choices can be found here:
78 # http://www.i18nguy.com/unicode/language-identifiers.html
79 LANGUAGE_CODE = 'en-us'
80
81 SITE_ID = 1
82
83 # If you set this to False, Django will make some optimizations so as not
84 # to load the internationalization machinery.
85 USE_I18N = True
86
87 # If you set this to False, Django will not format dates, numbers and
88 # calendars according to the current locale.
89 USE_L10N = True
90
91 # If you set this to False, Django will not use timezone-aware datetimes.
92 USE_TZ = True
93
94 # Absolute filesystem path to the directory that will hold user-uploaded files.
95 # Example: "/home/media/media.lawrence.com/media/"
96 MEDIA_ROOT = ''
97
98 # URL that handles the media served from MEDIA_ROOT. Make sure to use a
99 # trailing slash.
100 # Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
101 MEDIA_URL = ''
102
103 # Absolute path to the directory static files should be collected to.
104 # Don't put anything in this directory yourself; store your static files
105 # in apps' "static/" subdirectories and in STATICFILES_DIRS.
106 # Example: "/home/media/media.lawrence.com/static/"
107 STATIC_ROOT = os.path.join(HTTPROOT,'static')
108
109 # URL prefix for static files.
110 # Example: "http://media.lawrence.com/static/"
111 STATIC_URL = '/static/'
112
113 # Additional locations of static files
114 STATICFILES_DIRS = (
115     # Put strings here, like "/home/html/static" or "C:/www/django/static".
116     # Always use forward slashes, even on Windows.
117     # Don't forget to use absolute paths, not relative paths.
118     # Thierry : we do not need to detail the contents 
119     # of our 'apps' since they're mentioned in INSTALLED_APPS
120 )
121
122 # Needed by PluginFinder
123 PLUGIN_DIR = os.path.join(ROOT,'plugins')
124 # ThirdPartyFinder
125 THIRDPARTY_DIR = os.path.join(ROOT, 'third-party')
126
127 # List of finder classes that know how to find static files in
128 # various locations.
129 STATICFILES_FINDERS = (
130 # Thierry : no need for this one    
131 #    'django.contrib.staticfiles.finders.FileSystemFinder',
132     'django.contrib.staticfiles.finders.AppDirectoriesFinder',
133     'unfold.collectstatic.PluginFinder',
134     'unfold.collectstatic.ThirdPartyFinder',
135 ###    'django.contrib.staticfiles.finders.DefaultStorageFinder',
136 )
137
138 #TEMPLATE_CONTEXT_PROCESSORS = (
139 #    'django.contrib.auth.context_processors.auth',
140 #    'django.core.context_processors.debug',
141 #    'django.core.context_processors.i18n',
142 #    'django.core.context_processors.media',
143 #    'django.core.context_processors.static',
144 #    'django.core.context_processors.request',
145 #    'django.contrib.messages.context_processors.messages',
146 #)
147
148 # Make this unique, and don't share it with anybody.
149 SECRET_KEY = 't%n(3h)&r^n8(+8)(sp29t^$c2#t(m3)e2!02l8w1#36tl#t27'
150
151 # List of callables that know how to import templates from various sources.
152 TEMPLATE_LOADERS = (
153     'django.template.loaders.filesystem.Loader',
154     'django.template.loaders.app_directories.Loader',
155 #     'django.template.loaders.eggs.Loader',
156 )
157
158 MIDDLEWARE_CLASSES = (
159     'django.middleware.common.CommonMiddleware',
160     'django.contrib.sessions.middleware.SessionMiddleware',
161     'django.middleware.csrf.CsrfViewMiddleware',
162     'django.contrib.auth.middleware.AuthenticationMiddleware',
163     'django.contrib.messages.middleware.MessageMiddleware',
164     # Uncomment the next line for simple clickjacking protection:
165     # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
166 )
167
168 ROOT_URLCONF = 'myslice.urls'
169
170 # Python dotted path to the WSGI application used by Django's runserver.
171 WSGI_APPLICATION = 'unfold.wsgi.application'
172
173 TEMPLATE_DIRS = (
174     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
175     # Always use forward slashes, even on Windows.
176     # Don't forget to use absolute paths, not relative paths.
177     os.path.join(HTTPROOT,"templates"),
178 )
179
180 INSTALLED_APPS = [
181     'django.contrib.auth',
182     'django.contrib.contenttypes',
183     'django.contrib.sessions',
184     'django.contrib.sites',
185     'django.contrib.messages',
186     'django.contrib.staticfiles',
187     # handling the {% insert %} and {% container %} tags
188     # see details in devel/django-insert-above-1.0-4
189     'insert_above',
190     # our django project
191     'myslice',
192     # the core of the UI
193     'auth', 'manifold', 'unfold',
194     # plugins
195     'plugins',
196     # views - more or less stable 
197     'ui',
198     # managing database migrations
199     'south', 
200     # Uncomment the next line to enable the admin:
201     # 'django.contrib.admin',
202     # Uncomment the next line to enable admin documentation:
203     # 'django.contrib.admindocs',
204     'portal',
205 ]
206 for aux in auxiliaries:
207     if os.path.isdir(os.path.join(ROOT,aux)): 
208         print "Using devel auxiliary",aux
209         INSTALLED_APPS.append(aux)
210
211 ACCOUNT_ACTIVATION_DAYS = 7 # One-week activation window; you may, of course, use a different value.
212
213 # A sample logging configuration. The only tangible logging
214 # performed by this configuration is to send an email to
215 # the site admins on every HTTP 500 error when DEBUG=False.
216 # See http://docs.djangoproject.com/en/dev/topics/logging for
217 # more details on how to customize your logging configuration.
218 LOGGING = {
219     'version': 1,
220     'disable_existing_loggers': False,
221     'filters': {
222         'require_debug_false': {
223             '()': 'django.utils.log.RequireDebugFalse'
224         }
225     },
226     'handlers': {
227         'mail_admins': {
228             'level': 'ERROR',
229             'filters': ['require_debug_false'],
230             'class': 'django.utils.log.AdminEmailHandler',
231         }
232     },
233     'loggers': {
234         'django.request': {
235             'handlers': ['mail_admins'],
236             'level': 'ERROR',
237             'propagate': True,
238         },
239     }
240 }
241
242 AUTHENTICATION_BACKENDS = ( 'auth.manifoldbackend.ManifoldBackend', )
243
244 ### the view to redirect malformed (i.e. with a wrong CSRF) incoming requests
245 # without this setting django will return a 403 forbidden error, which is fine
246 # if you need to see the error message then use this setting
247 CSRF_FAILURE_VIEW = 'manifold.manifoldproxy.csrf_failure'
248
249 #################### for insert_above
250 #IA_JS_FORMAT = "<script type='text/javascript' src='{URL}' />"
251 # put stuff under static/
252 # IA_MEDIA_PREFIX = '/code/'