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