diff options
author | Marcel Hellkamp <marc@gsites.de> | 2012-07-20 20:53:09 +0200 |
---|---|---|
committer | Marcel Hellkamp <marc@gsites.de> | 2012-07-20 20:53:09 +0200 |
commit | cecbd04fc80e44f0b422b5bb7a894563102bed7f (patch) | |
tree | 11fb50ab11ab828424e99a0855df277315c0bb28 | |
parent | b652c4f1b587a6fa6af33d82a9f3482f0f934b3b (diff) | |
download | bottle-cecbd04fc80e44f0b422b5bb7a894563102bed7f.tar.gz |
Fix: Template cache now depends on the ID of the lookup path list.
Templates got mixed up in multi-app setups.
-rw-r--r-- | bottle.py | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -3089,21 +3089,22 @@ def template(*args, **kwargs): or directly (as keyword arguments). ''' tpl = args[0] if args else None - template_adapter = kwargs.pop('template_adapter', SimpleTemplate) + adapter = kwargs.pop('template_adapter', SimpleTemplate) + lookup = kwargs.pop('template_lookup', TEMPLATE_PATH) + tplid = (id(lookup), tpl) if tpl not in TEMPLATES or DEBUG: settings = kwargs.pop('template_settings', {}) - lookup = kwargs.pop('template_lookup', TEMPLATE_PATH) - if isinstance(tpl, template_adapter): - TEMPLATES[tpl] = tpl - if settings: TEMPLATES[tpl].prepare(**settings) + if isinstance(tpl, adapter): + TEMPLATES[tplid] = tpl + if settings: TEMPLATES[tplid].prepare(**settings) elif "\n" in tpl or "{" in tpl or "%" in tpl or '$' in tpl: - TEMPLATES[tpl] = template_adapter(source=tpl, lookup=lookup, **settings) + TEMPLATES[tplid] = adapter(source=tpl, lookup=lookup, **settings) else: - TEMPLATES[tpl] = template_adapter(name=tpl, lookup=lookup, **settings) - if not TEMPLATES[tpl]: + TEMPLATES[tplid] = adapter(name=tpl, lookup=lookup, **settings) + if not TEMPLATES[tplid]: abort(500, 'Template (%s) not found' % tpl) for dictarg in args[1:]: kwargs.update(dictarg) - return TEMPLATES[tpl].render(kwargs) + return TEMPLATES[tplid].render(kwargs) mako_template = functools.partial(template, template_adapter=MakoTemplate) cheetah_template = functools.partial(template, template_adapter=CheetahTemplate) |