forked from diN0bot/ProcrasDonate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsettings.py
215 lines (176 loc) · 6.85 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# Global Django settings for ProcrasDonate project
# For help setting up local settings, see the dev-flock wiki:
# http://bilumi.org/trac/wiki/FAQ#Projectsetupoptional
import os
def path(p):
"""
@param p: path with *nix path separator
@return: string with os-specific path separator
"""
return os.sep.join(p.split("/"))
import re
_space_replace = re.compile("([^\\\])( )")
def pathify(lst, file_extension=False):
"""
@param lst: list of path components
@return: string with os-specific path separator between components
"""
# replaces spaces with raw spaces so that spaces in file names work
repl = r"\g<1> "
return os.sep.join([_space_replace.sub(repl, el) for el in lst])
#if file_extension:
# return os.sep.join([el != lst[-1] and _space_replace.sub(repl, el.replace('.', os.sep)) or _space_replace.sub(repl, el) for el in lst])
#else:
# return os.sep.join([_space_replace.sub(repl, el.replace('.', os.sep)) for el in lst])
import sys
if not sys.stdout:
# fail on windows?
#sys.stdout = file(path('/dev/null'),"w")
sys.stdout = file(path('/var/log/apache2/whynoti.org/stdout.log'),"a")
PROJECT_PATH = os.path.dirname(os.path.realpath(__file__))
DEBUG = False # True for general debug mode, eg, will display debug info rather than 404 or 500
DJANGO_SERVER = False # True if using django's runserver
TEMPLATE_DEBUG = DEBUG # Template exceptions won't crash rendering, plus mroe useful exception message is shown in console.
DEBUG_SQL = DEBUG # not sure
DEBUG_TOOLBAR = False # True to show debug toolbar at top of page
DEBUG_PROPAGATE_EXCEPTIONS = DEBUG # For twill tests
ADMINS = (
('Lucy', '[email protected]')
)
MANAGERS = ADMINS
APPS = ('procrasdonate',
'crosstester',
'adwords',
'procrasdocoder',
'rescuetime_interface')
#'weddings')
EMAIL = "[email protected]"
DOMAIN = 'http://procrasdonate.com'
API_DOMAIN = 'https://procrasdonate.com'
# Local time zone for this installation. Choices can be found here:
# http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
# although not all variations may be possible on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/New_York'
# Language code for this installation. All choices can be found here:
# http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
# http://blogs.law.harvard.edu/tech/stories/storyReader$15
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
ROOT_URLCONF = 'urls'
DOWN_FOR_MAINTENANCE = False
# check this out: http://www.djangosnippets.org/snippets/1068/
# Absolute path to the directory that holds media.
# including upload image directory
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = pathify([PROJECT_PATH, path('media/')])
# URL that handles the media served from MEDIA_ROOT.
# Example: "http://media.lawrence.com"
MEDIA_URL = '/procrasdonate_media/'
# Number of days a user has at most to activate his/her account.
ACCOUNT_ACTIVATION_DAYS = 10
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'somethingsekret'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
MIDDLEWARE_CLASSES = (
'django.middleware.doc.XViewMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'ext.pagination.middleware.PaginationMiddleware',
#'django.contrib.csrf.middleware.CsrfMiddleware',
#'lib.ssl_middleware.SSLRedirect',
)
for app in APPS:
if os.path.exists(pathify([PROJECT_PATH, app, 'middleware.py'], file_extension=True)):
MIDDLEWARE_CLASSES += (
'%s.middleware.%sMiddleware' % (app, app.capitalize()),
)
if DEBUG_TOOLBAR:
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
TEMPLATE_DIRS = (
#'procrasdonate/ProcrasDonateFFExtn/content/templates',
pathify([PROJECT_PATH, path('procrasdonate/ProcrasDonateFFExtn/content/templates')]),
)
for app in APPS:
if os.path.exists(pathify([PROJECT_PATH, app, 'templates'])):
TEMPLATE_DIRS += (
pathify([PROJECT_PATH, path('%s/templates' % app)]),
)
INSTALLED_APPS = (
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.humanize',
'ext.pagination',
'django.contrib.auth',
'django.contrib.admindocs',
'django.contrib.admin',
)
for app in APPS:
INSTALLED_APPS += (
app,
)
AUTH_PROFILE_MODULE = 'procrasdonate.RecipientUserTagging'
LOGIN_URL = '/recipient/login/'
LOGOUT_URL = '/recipient/logout/'
USE_MARKUP = True
if USE_MARKUP:
INSTALLED_APPS += ('django.contrib.markup',)
if DEBUG_TOOLBAR:
INSTALLED_APPS += ('debug_toolbar',)
PAGINATE_TEMPLATE = 'procrasdonate/pagination.html'
TEMPLATE_CONTEXT_PROCESSORS = (
'lib.context.defaults',
'django.core.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
)
for app in APPS:
if os.path.exists(pathify([PROJECT_PATH, app, 'context.py'], file_extension=True)):
TEMPLATE_CONTEXT_PROCESSORS += (
'%s.context.defaults' % app,
)
"""
Determine the environment:
1. env/CURRENT should contain a single line of text that matches a directory name in env
If env/CURRENT does not exist, use env/CURRENT.default
2. Load settings.py from the named directory
Note that env/CURRENT.default and the folder it points to (eg, sqlite3_default) should
be checked into the repository.
** env/CURRENT should not be checked into the repostiroy **
Other folders may be checked in to manage setting revisions, but be careful about
revealing database passwords.
"""
env_file = PROJECT_PATH+path("/env/CURRENT")
def_env_file = PROJECT_PATH+path("/env/CURRENT.default")
if os.path.exists(env_file):
f = file(env_file)
elif os.path.exists(def_env_file):
f = file(def_env_file)
else:
raise IOError(env_file+" or "+def_env_file+" do not exist! Please specify an environment\nhttp://bilumi.org/trac/wiki/FAQ.")
DEV_ENV = f.read().strip()
f.close()
env_settings_file = PROJECT_PATH+path("/env/"+DEV_ENV+"/settings.py")
try:
f = file(env_settings_file)
except IOError, e:
raise IOError(env_settings_file+" does not exist! Please create this file.")
else:
env_settings = f.read()
f.close()
code = compile(env_settings, env_settings_file, 'exec')
exec(code)