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