Add jinja2 bytecode caching and remove werkzeug from requirements-prod.txt

This commit is contained in:
Wil Clouser 2010-02-03 13:46:15 -08:00
Родитель 0ba3fe9fcb
Коммит fdb0437fb9
3 изменённых файлов: 24 добавлений и 2 удалений

Просмотреть файл

@ -21,7 +21,13 @@ def get_env():
'auto_reload': settings.DEBUG, 'auto_reload': settings.DEBUG,
'loader': jinja2.ChoiceLoader(loaders), 'loader': jinja2.ChoiceLoader(loaders),
} }
opts.update(getattr(settings, 'JINJA_CONFIG', {}))
if hasattr(settings, 'JINJA_CONFIG'):
if hasattr(settings.JINJA_CONFIG, '__call__'):
config = settings.JINJA_CONFIG()
else:
config = settings.JINJA_CONFIG
opts.update(config)
e = jinja2.Environment(**opts) e = jinja2.Environment(**opts)
# TODO: use real translations # TODO: use real translations

Просмотреть файл

@ -2,7 +2,6 @@
Jinja2==2.2.1 Jinja2==2.2.1
MySQL-python==1.2.3c1 MySQL-python==1.2.3c1
python-memcached==1.45 python-memcached==1.45
Werkzeug==0.5.1
Babel==0.9.4 Babel==0.9.4
phpserialize phpserialize
south south

Просмотреть файл

@ -187,6 +187,23 @@ TEST_RUNNER = 'test_utils.runner.RadicalTestSuiteRunner'
LOG_LEVEL = logging.DEBUG LOG_LEVEL = logging.DEBUG
def JINJA_CONFIG():
import jinja2
from django.conf import settings
from caching.base import cache
config = {}
if 'memcached' in cache.scheme and not settings.DEBUG:
# We're passing the _cache object directly to jinja because
# Django can't store binary directly; it enforces unicode on it.
# Details: http://jinja.pocoo.org/2/documentation/api#bytecode-cache
# and in the errors you get when you try it the other way.
bc = jinja2.MemcachedBytecodeCache(cache._cache,
"%sj2:" % settings.CACHE_PREFIX)
config['cache_size'] = -1 # Never clear the cache
config['bytecode_cache'] = bc
return config
# Full base URL for your main site including protocol. No trailing slash. # Full base URL for your main site including protocol. No trailing slash.
# Example: https://addons.mozilla.org # Example: https://addons.mozilla.org
SITE_URL = 'http://%s' % socket.gethostname() SITE_URL = 'http://%s' % socket.gethostname()