]> git.openstreetmap.org Git - osqa.git/blob - settings.py
Migrate to Django 1.6
[osqa.git] / settings.py
1 # encoding:utf-8
2 import os.path
3 import sys
4
5 SITE_ID = 1
6
7 ADMIN_MEDIA_PREFIX = '/admin_media/'
8 SECRET_KEY = 'a;::qCl1mfh?avagttOJ;8f5Rr54d,9qy7;o15M2cYO75?OQo51u3LnQ;!8N.:,7'
9
10 CACHE_MAX_KEY_LENGTH = 235
11
12 MIDDLEWARE_CLASSES = [
13     'django.middleware.csrf.CsrfViewMiddleware',
14     'forum.middleware.django_cookies.CookiePreHandlerMiddleware',
15     'django.contrib.sessions.middleware.SessionMiddleware',
16     'django.contrib.messages.middleware.MessageMiddleware',
17     'django.middleware.common.CommonMiddleware',
18     'forum.middleware.extended_user.ExtendedUser',
19     'forum.middleware.anon_user.ConnectToSessionMessagesMiddleware',
20     'forum.middleware.request_utils.RequestUtils',
21     'forum.middleware.cancel.CancelActionMiddleware',
22     'forum.middleware.admin_messages.AdminMessagesMiddleware',
23     'forum.middleware.custom_pages.CustomPagesFallbackMiddleware',
24     'django.middleware.transaction.TransactionMiddleware',
25     'forum.middleware.django_cookies.CookiePostHandlerMiddleware',
26 ]
27
28 TEMPLATE_CONTEXT_PROCESSORS = [
29     'django.core.context_processors.request',
30     'forum.context.application_settings',
31     'django.contrib.messages.context_processors.messages',
32     'forum.user_messages.context_processors.user_messages',
33     'django.contrib.auth.context_processors.auth',
34 ]
35
36 ROOT_URLCONF = 'urls'
37 APPEND_SLASH = True
38
39 TEMPLATE_DIRS = (
40     os.path.join(os.path.dirname(__file__),'forum','skins').replace('\\','/'),
41 )
42
43
44 FILE_UPLOAD_TEMP_DIR = os.path.join(os.path.dirname(__file__), 'tmp').replace('\\','/')
45 FILE_UPLOAD_HANDLERS = ("django.core.files.uploadhandler.MemoryFileUploadHandler",
46  "django.core.files.uploadhandler.TemporaryFileUploadHandler",)
47 DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'
48
49 ALLOW_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
50 ALLOW_MAX_FILE_SIZE = 1024 * 1024
51
52 SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer'
53
54 MESSAGE_STORAGE = 'django.contrib.messages.storage.session.SessionStorage'
55
56 # User settings
57 from settings_local import *
58
59 template_loaders = (
60     'django.template.loaders.filesystem.Loader',
61     'django.template.loaders.app_directories.Loader',
62     'forum.modules.template_loader.module_templates_loader',
63     'forum.skins.load_template_source',
64 )
65 TEMPLATE_LOADERS = list(template_loaders) if DEBUG else [ ('django.template.loaders.cached.Loader', template_loaders) ]
66
67 try:
68     if len(FORUM_SCRIPT_ALIAS) > 0:
69         APP_URL = '%s/%s' % (APP_URL, FORUM_SCRIPT_ALIAS[:-1])
70 except NameError:
71     pass
72
73 app_url_split = APP_URL.split("://")
74
75 APP_PROTOCOL = app_url_split[0]
76 APP_DOMAIN = app_url_split[1].split('/')[0]
77 APP_BASE_URL = '%s://%s' % (APP_PROTOCOL, APP_DOMAIN)
78
79 FORCE_SCRIPT_NAME = ''
80
81 for path in app_url_split[1].split('/')[1:]:
82     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME + '/' + path
83
84 if FORCE_SCRIPT_NAME.endswith('/'):
85     FORCE_SCRIPT_NAME = FORCE_SCRIPT_NAME[:-1]
86
87 #Module system initialization
88 MODULES_PACKAGE = 'forum_modules'
89 MODULES_FOLDER = os.path.join(SITE_SRC_ROOT, MODULES_PACKAGE)
90
91 MODULE_LIST = filter(lambda m: getattr(m, 'CAN_USE', True), [
92         __import__('forum_modules.%s' % f, globals(), locals(), ['forum_modules'])
93         for f in os.listdir(MODULES_FOLDER)
94         if os.path.isdir(os.path.join(MODULES_FOLDER, f)) and
95            os.path.exists(os.path.join(MODULES_FOLDER, "%s/__init__.py" % f)) and
96            not f in DISABLED_MODULES
97 ])
98
99 [MIDDLEWARE_CLASSES.extend(
100         ["%s.%s" % (m.__name__, mc) for mc in getattr(m, 'MIDDLEWARE_CLASSES', [])]
101                           ) for m in MODULE_LIST]
102
103 [TEMPLATE_LOADERS.extend(
104         ["%s.%s" % (m.__name__, tl) for tl in getattr(m, 'TEMPLATE_LOADERS', [])]
105                           ) for m in MODULE_LIST]
106
107
108 INSTALLED_APPS = [
109     'django.contrib.auth',
110     'django.contrib.contenttypes',
111     'django.contrib.sessions',
112     'django.contrib.sites',
113     'django.contrib.admin',
114     'django.contrib.humanize',
115     'django.contrib.sitemaps',
116     'django.contrib.messages',
117     'forum',
118 ]
119
120 if DEBUG:
121     try:
122         import debug_toolbar
123         MIDDLEWARE_CLASSES.append('debug_toolbar.middleware.DebugToolbarMiddleware')
124         INSTALLED_APPS.append('debug_toolbar')
125     except:
126         pass
127
128 try:
129     import south
130     INSTALLED_APPS.append('south')
131 except:
132     pass
133
134 # Try loading Gunicorn web server
135 try:
136     import gunicorn
137     INSTALLED_APPS.append('gunicorn')
138 except ImportError:
139     pass
140
141 if not DEBUG:
142     try:
143         import rosetta
144         INSTALLED_APPS.append('rosetta')
145     except:
146         pass
147
148 AUTHENTICATION_BACKENDS = ['django.contrib.auth.backends.ModelBackend',]