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