7 BASE_DIR
= os
.path
.dirname(os
.path
.abspath(__file__
))
10 def get_bool(name
, default
):
11 return os
.getenv(name
, str(default
)).lower() == 'true'
14 def get_intOrNone(name
, default
):
15 """ Parses the env variable, accepts ints and literal None"""
16 value
= os
.getenv(name
, str(default
))
17 if value
.lower() == 'none':
22 DEBUG
= get_bool('DEBUG', False)
24 ADMINS
= re
.findall(r
'\s*([^<]+) <([^>]+)>\s*', os
.getenv('ADMINS', ''))
29 'default': dj_database_url
.config(
30 default
='postgres://mygpo:mygpo@localhost/mygpo'),
34 _cache_used
= bool(os
.getenv('CACHE_BACKEND', False))
41 'django.core.cache.backends.memcached.MemcachedCache'),
42 'LOCATION': os
.getenv('CACHE_LOCATION'),
46 # Local time zone for this installation. Choices can be found here:
47 # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
48 # although not all choices may be available on all operating systems.
49 # If running in a Windows environment this must be set to the same as your
53 # Language code for this installation. All choices can be found here:
54 # http://www.i18nguy.com/unicode/language-identifiers.html
55 LANGUAGE_CODE
= 'en-us'
59 # If you set this to False, Django will make some optimizations so as not
60 # to load the internationalization machinery.
63 STATIC_ROOT
= 'staticfiles'
64 STATIC_URL
= '/media/'
67 os
.path
.abspath(os
.path
.join(BASE_DIR
, '..', 'htdocs', 'media')),
72 'BACKEND': 'django.template.backends.django.DjangoTemplates',
76 'context_processors': [
77 'django.contrib.auth.context_processors.auth',
78 'django.template.context_processors.debug',
79 'django.template.context_processors.i18n',
80 'django.template.context_processors.media',
81 'django.template.context_processors.static',
82 'django.template.context_processors.tz',
83 'django.contrib.messages.context_processors.messages',
84 'mygpo.web.google.analytics',
85 'mygpo.web.google.adsense',
86 # make the debug variable available in templates
87 # https://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-debug
88 'django.template.context_processors.debug',
90 # required so that the request obj can be accessed from
91 # templates. this is used to direct users to previous
93 'django.template.context_processors.request',
96 'staticfiles' : 'django.templatetags.static',
99 ('django.template.loaders.cached.Loader', [
100 'django.template.loaders.app_directories.Loader',
108 'django.middleware.common.CommonMiddleware',
109 'django.middleware.csrf.CsrfViewMiddleware',
110 'django.contrib.sessions.middleware.SessionMiddleware',
111 'django.contrib.auth.middleware.AuthenticationMiddleware',
112 'django.middleware.locale.LocaleMiddleware',
113 'django.contrib.messages.middleware.MessageMiddleware',
116 ROOT_URLCONF
= 'mygpo.urls'
119 'django.contrib.contenttypes',
120 'django.contrib.messages',
121 'django.contrib.admin',
122 'django.contrib.humanize',
123 'django.contrib.auth',
124 'django.contrib.sessions',
125 'django.contrib.staticfiles',
126 'django.contrib.sites',
136 'mygpo.subscriptions',
139 'mygpo.usersettings',
145 'mygpo.episodestates',
148 'mygpo.administration',
150 'mygpo.podcastlists',
158 INSTALLED_APPS
+= ['debug_toolbar']
159 MIDDLEWARE
+= ['debug_toolbar.middleware.DebugToolbarMiddleware']
169 INSTALLED_APPS
+= ['opbeat.contrib.django']
175 ACCOUNT_ACTIVATION_DAYS
= int(os
.getenv('ACCOUNT_ACTIVATION_DAYS', 7))
177 AUTHENTICATION_BACKENDS
= (
178 'mygpo.users.backend.CaseInsensitiveModelBackend',
179 'mygpo.web.auth.EmailAuthenticationBackend',
182 SESSION_ENGINE
= "django.contrib.sessions.backends.cached_db"
184 # TODO: use (default) JSON serializer for security
185 # this would currently fail as we're (de)serializing datetime objects
186 # https://docs.djangoproject.com/en/1.5/topics/http/sessions/#session-serialization
187 SESSION_SERIALIZER
= 'django.contrib.sessions.serializers.PickleSerializer'
190 MESSAGE_STORAGE
= 'django.contrib.messages.storage.session.SessionStorage'
192 USER_CLASS
= 'mygpo.users.models.User'
194 LOGIN_URL
= '/login/'
196 CSRF_FAILURE_VIEW
= 'mygpo.web.views.csrf_failure'
199 DEFAULT_FROM_EMAIL
= os
.getenv('DEFAULT_FROM_EMAIL', '')
201 SECRET_KEY
= os
.getenv('SECRET_KEY', '')
203 if 'test' in sys
.argv
:
206 GOOGLE_ANALYTICS_PROPERTY_ID
= os
.getenv('GOOGLE_ANALYTICS_PROPERTY_ID', '')
208 DIRECTORY_EXCLUDED_TAGS
= os
.getenv('DIRECTORY_EXCLUDED_TAGS', '').split()
210 FLICKR_API_KEY
= os
.getenv('FLICKR_API_KEY', '')
212 SOUNDCLOUD_CONSUMER_KEY
= os
.getenv('SOUNDCLOUD_CONSUMER_KEY', '')
214 MAINTENANCE
= get_bool('MAINTENANCE', False)
217 ALLOWED_HOSTS
= ['*']
222 'disable_existing_loggers': False,
225 'format': '%(asctime)s %(name)s %(levelname)s %(message)s',
229 'require_debug_false': {
230 '()': 'django.utils.log.RequireDebugFalse'
235 'level': os
.getenv('LOGGING_CONSOLE_LEVEL', 'DEBUG'),
236 'class': 'logging.StreamHandler',
237 'formatter': 'verbose',
241 'filters': ['require_debug_false'],
242 'class': 'django.utils.log.AdminEmailHandler',
247 'handlers': os
.getenv('LOGGING_DJANGO_HANDLERS',
250 'level': os
.getenv('LOGGING_DJANGO_LEVEL', 'WARN'),
253 'handlers': os
.getenv('LOGGING_MYGPO_HANDLERS', 'console').split(),
254 'level': os
.getenv('LOGGING_MYGPO_LEVEL', 'INFO'),
257 'handlers': os
.getenv('LOGGING_CELERY_HANDLERS',
259 'level': os
.getenv('LOGGING_CELERY_LEVEL', 'DEBUG'),
264 _use_log_file
= bool(os
.getenv('LOGGING_FILENAME', False))
267 LOGGING
['handlers']['file'] = {
269 'class': 'logging.handlers.RotatingFileHandler',
270 'filename': os
.getenv('LOGGING_FILENAME'),
271 'maxBytes': 10000000,
273 'formatter': 'verbose',
277 # minimum number of subscribers a podcast must have to be assigned a slug
278 PODCAST_SLUG_SUBSCRIBER_LIMIT
= int(os
.getenv(
279 'PODCAST_SLUG_SUBSCRIBER_LIMIT', 10))
281 # minimum number of subscribers that a podcast needs to "push" one of its
282 # categories to the top
283 MIN_SUBSCRIBERS_CATEGORY
= int(os
.getenv('MIN_SUBSCRIBERS_CATEGORY', 10))
285 # maximum number of episode actions that the API processes immediatelly before
286 # returning the response. Larger requests will be handled in background.
287 # Handler can be set to None to disable
288 API_ACTIONS_MAX_NONBG
= int(os
.getenv('API_ACTIONS_MAX_NONBG', 100))
289 API_ACTIONS_BG_HANDLER
= 'mygpo.api.tasks.episode_actions_celery_handler'
292 ADSENSE_CLIENT
= os
.getenv('ADSENSE_CLIENT', '')
294 ADSENSE_SLOT_BOTTOM
= os
.getenv('ADSENSE_SLOT_BOTTOM', '')
296 # we're running behind a proxy that sets the X-Forwarded-Proto header correctly
297 # see https://docs.djangoproject.com/en/dev/ref/settings/#secure-proxy-ssl-header
298 SECURE_PROXY_SSL_HEADER
= ('HTTP_X_FORWARDED_PROTO', 'https')
301 # enabled access to staff-only areas with ?staff=<STAFF_TOKEN>
302 STAFF_TOKEN
= os
.getenv('STAFF_TOKEN', None)
304 # Flattr settings -- available after you register your app
305 FLATTR_KEY
= os
.getenv('FLATTR_KEY', '')
306 FLATTR_SECRET
= os
.getenv('FLATTR_SECRET', '')
308 # Flattr thing of the webservice. Will be flattr'd when a user sets
309 # the "Auto-Flattr gpodder.net" option
310 FLATTR_MYGPO_THING
= os
.getenv(
311 'FLATTR_MYGPO_THING',
312 'https://flattr.com/submit/auto?user_id=stefankoegl&url=http://gpodder.net'
315 # The User-Agent string used for outgoing HTTP requests
316 USER_AGENT
= 'gpodder.net (+https://github.com/gpodder/mygpo)'
318 # Base URL of the website that is used if the actually used parameters is not
319 # available. Request handlers, for example, can access the requested domain.
320 # Code that runs in background can not do this, and therefore requires a
321 # default value. This should be set to something like 'http://example.com'
322 DEFAULT_BASE_URL
= os
.getenv('DEFAULT_BASE_URL', '')
327 BROKER_URL
= os
.getenv('BROKER_URL', 'redis://localhost')
328 CELERY_RESULT_BACKEND
= 'djcelery.backends.database:DatabaseBackend'
330 SERVER_EMAIL
= os
.getenv('SERVER_EMAIL', 'no-reply@example.com')
332 CELERY_TASK_RESULT_EXPIRES
= 60 * 60 # 1h expiry time in seconds
334 CELERY_ACCEPT_CONTENT
= ['pickle', 'json']
336 CELERY_SEND_TASK_ERROR_EMAILS
= get_bool('CELERY_SEND_TASK_ERROR_EMAILS',
339 BROKER_POOL_LIMIT
= get_intOrNone('BROKER_POOL_LIMIT', 10)
343 GOOGLE_CLIENT_ID
= os
.getenv('GOOGLE_CLIENT_ID', '')
344 GOOGLE_CLIENT_SECRET
= os
.getenv('GOOGLE_CLIENT_SECRET', '')
346 # URL where users of the site can get support
347 SUPPORT_URL
= os
.getenv('SUPPORT_URL', '')
350 FEEDSERVICE_URL
= os
.getenv('FEEDSERVICE_URL', 'http://feeds.gpodder.net/')
352 # Elasticsearch settings
354 ELASTICSEARCH_SERVER
= os
.getenv('ELASTICSEARCH_SERVER', '127.0.0.1:9200')
355 ELASTICSEARCH_INDEX
= os
.getenv('ELASTICSEARCH_INDEX', 'mygpo')
356 ELASTICSEARCH_TIMEOUT
= float(os
.getenv('ELASTICSEARCH_TIMEOUT', '2'))
358 # time for how long an activation is valid; after that, an unactivated user
360 ACTIVATION_VALID_DAYS
= int(os
.getenv('ACTIVATION_VALID_DAYS', 10))
364 "ORGANIZATION_ID": os
.getenv('OPBEAT_ORGANIZATION_ID', ''),
365 "APP_ID": os
.getenv('OPBEAT_APP_ID', ''),
366 "SECRET_TOKEN": os
.getenv('OPBEAT_SECRET_TOKEN', ''),
370 os
.path
.abspath(os
.path
.join(BASE_DIR
, 'locale')),
373 INTERNAL_IPS
= os
.getenv('INTERNAL_IPS', '').split()
375 EMAIL_BACKEND
= os
.getenv('EMAIL_BACKEND',
376 'django.core.mail.backends.smtp.EmailBackend')
378 PODCAST_AD_ID
= os
.getenv('PODCAST_AD_ID')
380 TEST_RUNNER
= 'django_nose.NoseTestSuiteRunner'