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