-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprod.py
135 lines (119 loc) · 3.93 KB
/
prod.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
from common import * # NOQA
from os import environ
# DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
#DEBUG = bool(environ.get('DJANGO_DEBUG', ''))
DEBUG = environ.get('DJANGO_DEBUG', False)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
# ########## END DEBUG CONFIGURATION
# DATABASE CONFIGURATION
# Parse database configuration from $DATABASE_URL
import dj_database_url
DATABASES['default'] = dj_database_url.config()
# END DATABASE CONFIGURATION
# Honor the 'X-Forwarded-Proto' header for request.is_secure()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Limit Host and Referrer headers for security purposes
# See
# https://docs.djangoproject.com/en/1.6/ref/settings/#std:setting-ALLOWED_HOSTS
ALLOWED_HOSTS = environ.get('ALLOWED_HOSTS', '*').split(',')
# ALLOWED_HOSTS = [
# '.recal.io', # Allow domain and subdomains
# '.recal.io.', # Also allow FQDN and subdomains
# 'herokuapp.com',
# 'localhost', # Allow foreman to run
# ]
SECRET_KEY = environ.get(
'DJANGO_SECRET_KEY', 'asdfasfshjkxhvkzjxhiu1012u4-9r0iojsof')
def get_cache():
try:
environ['MEMCACHE_SERVERS'] = environ[
'MEMCACHIER_SERVERS'].replace(',', ';')
environ['MEMCACHE_USERNAME'] = environ['MEMCACHIER_USERNAME']
environ['MEMCACHE_PASSWORD'] = environ['MEMCACHIER_PASSWORD']
return {
'default': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'my_cache_table',
'TIMEOUT': 60 * 60
},
'courses': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'courses_cache_table',
'TIMEOUT': 60 * 60
},
'courseapi': {
'BACKEND': 'django.core.cache.backends.db.DatabaseCache',
'LOCATION': 'courseapi_cache_table',
'TIMEOUT': 60 * 60
},
'memcache': {
'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
'TIMEOUT': 500,
'BINARY': True,
'OPTIONS': {
'tcp_nodelay': True
}
}
}
except:
# local memory caches
return {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
},
'courses': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
},
'courseapi': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'
}
}
CACHES = get_cache()
# TOOLBAR CONFIGURATION
# See:
# https://github.com/django-debug-toolbar/django-debug-toolbar#installation
INSTALLED_APPS += (
#'debug_toolbar',
)
# ADMINS = (('Naphat'), ('[email protected]'))
# See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
#INTERNAL_IPS = ('127.0.0.1',)
#
#DEBUG_TOOLBAR_PATCH_SETTINGS = False
# TODO: updated DDT, need to update these settings when deploying
# # See: https://github.com/django-debug-toolbar/django-debug-toolbar#installation
# MIDDLEWARE_CLASSES += (
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
# )
#
# DEBUG_TOOLBAR_CONFIG = {
# 'INTERCEPT_REDIRECTS': False,
# }
# END TOOLBAR CONFIGURATION
LOGGING = {
'version': 1,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
},
'loggers': {
'django': {
'handlers': ['console'],
'level': 'DEBUG',
'propagate': True,
},
}
}