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