Add jinja2 bytecode caching and remove werkzeug from requirements-prod.txt
This commit is contained in:
Родитель
0ba3fe9fcb
Коммит
fdb0437fb9
|
@ -21,7 +21,13 @@ def get_env():
|
|||
'auto_reload': settings.DEBUG,
|
||||
'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)
|
||||
# TODO: use real translations
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
Jinja2==2.2.1
|
||||
MySQL-python==1.2.3c1
|
||||
python-memcached==1.45
|
||||
Werkzeug==0.5.1
|
||||
Babel==0.9.4
|
||||
phpserialize
|
||||
south
|
||||
|
|
17
settings.py
17
settings.py
|
@ -187,6 +187,23 @@ TEST_RUNNER = 'test_utils.runner.RadicalTestSuiteRunner'
|
|||
|
||||
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.
|
||||
# Example: https://addons.mozilla.org
|
||||
SITE_URL = 'http://%s' % socket.gethostname()
|
||||
|
|
Загрузка…
Ссылка в новой задаче