In reply to myself.
the function frender(filename, ...) returns a Template object. You can
cache such an object in your own application.
A far-from-perfect and far-from-flawless caching mechanism can be
implemented as following:
# do not cache when running under debug mode
if not web.webapi.config.get('debug', False):
cache = {}
else:
cache = None
def getTemplate(self, filename, globals):
if cache == None:
return web.template.frender(filename, globals=globals)
# returns cached object, if not in cache, cache it first
if filename not in cache:
cache[filename] = web.template.frender(filename,
globals=globals)
return cache[filename]
template = getTemplate(filename, globals={})
return template(foo="bar")
Remco
On Feb 5, 5:26 pm, Remco <[email protected]> wrote:
> Hey group,
>
> As I am using .frender() for compiling my templates I noticed that it
> does not cache these compiled files. I checked the template.py code
> and played a bit with it and it does indeed seem not cache frender
> calls. So a few questions here: is this correct and expected behavior
> not to cache frendered files/results, and is caching from frender-
> templates undesired?
>
> Regards,
> Remco
--
You received this message because you are subscribed to the Google Groups
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/webpy?hl=en.