annotate mysite/settings/production.py @ 37:c1f3658830e0

Add middleware to support site-wide caching for anonymous users.
author Brian Neal <bgneal@gmail.com>
date Wed, 30 Nov 2011 00:21:51 +0000
parents 21172e9be136
children
rev   line source
bgneal@34 1 # Django production settings for the madeira project.
bgneal@34 2
bgneal@34 3 from settings.base import *
bgneal@34 4
bgneal@34 5 DEBUG = False
bgneal@34 6 TEMPLATE_DEBUG = DEBUG
bgneal@34 7
bgneal@34 8 DATABASES = {
bgneal@34 9 'default': {
bgneal@34 10 'ENGINE': 'django.db.backends.mysql',
bgneal@34 11 'NAME': 'madeira_django',
bgneal@34 12 'USER': SECRETS['DB_USER'],
bgneal@34 13 'PASSWORD': SECRETS['DB_PASSWORD'],
bgneal@34 14 },
bgneal@34 15 }
bgneal@34 16
bgneal@34 17 STATIC_ROOT = os.path.abspath(os.path.join(PROJECT_PATH, '..', 'static_serve'))
bgneal@34 18
bgneal@34 19 TEMPLATE_LOADERS = [
bgneal@34 20 ('django.template.loaders.cached.Loader', (
bgneal@34 21 'django.template.loaders.filesystem.Loader',
bgneal@34 22 'django.template.loaders.app_directories.Loader',
bgneal@34 23 )),
bgneal@34 24 ]
bgneal@34 25
bgneal@34 26 CACHES = {
bgneal@34 27 'default': {
bgneal@34 28 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
bgneal@34 29 'LOCATION': '127.0.0.1:11211',
bgneal@34 30 'TIMEOUT': 600,
bgneal@34 31 },
bgneal@34 32 }
bgneal@34 33 CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
bgneal@34 34 CACHE_MIDDLEWARE_SECONDS = 600
bgneal@34 35 CACHE_MIDDLEWARE_KEY_PREFIX = ''
bgneal@34 36
bgneal@37 37 MIDDLEWARE_CLASSES.insert(0, 'django.middleware.cache.UpdateCacheMiddleware')
bgneal@37 38 MIDDLEWARE_CLASSES.append('django.middleware.cache.FetchFromCacheMiddleware')
bgneal@37 39
bgneal@34 40 EMAIL_HOST = 'localhost'
bgneal@34 41 EMAIL_PORT = 25
bgneal@34 42
bgneal@34 43 LOGGING = {
bgneal@34 44 'version': 1,
bgneal@34 45 'disable_existing_loggers': True,
bgneal@34 46 'formatters': {
bgneal@34 47 'verbose': {
bgneal@34 48 'format': '%(asctime)s %(levelname)s %(module)s %(process)d %(thread)d %(message)s'
bgneal@34 49 },
bgneal@34 50 'simple': {
bgneal@34 51 'format': '%(asctime)s %(levelname)s %(message)s'
bgneal@34 52 },
bgneal@34 53 },
bgneal@34 54 'handlers': {
bgneal@34 55 'console': {
bgneal@34 56 'class': 'logging.StreamHandler',
bgneal@34 57 'level': 'DEBUG',
bgneal@34 58 'formatter': 'simple',
bgneal@34 59 },
bgneal@34 60 'file': {
bgneal@34 61 'class': 'logging.handlers.RotatingFileHandler',
bgneal@34 62 'level': 'DEBUG',
bgneal@34 63 'formatter': 'simple',
bgneal@35 64 'filename': os.path.join(PROJECT_PATH, 'logs', 'madeira.log'),
bgneal@34 65 'mode': 'a',
bgneal@34 66 'maxBytes': 100 * 1024,
bgneal@34 67 'backupCount': 10,
bgneal@34 68 },
bgneal@34 69 'mail_admins': {
bgneal@34 70 'class': 'django.utils.log.AdminEmailHandler',
bgneal@34 71 'level': 'ERROR',
bgneal@34 72 'formatter': 'simple',
bgneal@34 73 },
bgneal@34 74 },
bgneal@34 75 'loggers': {
bgneal@34 76 'django':{
bgneal@34 77 'level': 'WARNING',
bgneal@34 78 'propagate': False,
bgneal@34 79 'handlers': ['file'],
bgneal@34 80 },
bgneal@34 81 'django.request':{
bgneal@34 82 'level': 'ERROR',
bgneal@34 83 'propagate': True,
bgneal@34 84 'handlers': ['mail_admins'],
bgneal@34 85 },
bgneal@34 86 },
bgneal@34 87 'root': {
bgneal@34 88 'level': 'INFO',
bgneal@34 89 'handlers': ['file'],
bgneal@34 90 },
bgneal@34 91 }