4
from zope.pagetemplate import pagetemplatefile
9
def _compile_template(tfile):
10
mod = PageTemplate(tfile)
11
mtime = os.stat(tfile).st_mtime
16
if tfile in _zpt_cache:
17
mtime = os.stat(tfile).st_mtime
18
mod = _zpt_cache[tfile]
19
if mod.__mtime__ != mtime:
20
mod = _compile_template(tfile)
21
_zpt_cache[tfile] = mod
23
mod = _zpt_cache[tfile] = _compile_template(tfile)
27
def __init__(self, base, options):
29
self.options = options
31
def __getitem__(self, name):
32
return zpt(os.path.join(self.base, name))(**self.options)
34
class PageTemplate(pagetemplatefile.PageTemplateFile):
35
def __init__(self, name):
36
self.base = os.path.dirname(name)
37
pagetemplatefile.PageTemplateFile.__init__(self, name)
39
def pt_getContext(self, args=(), options={}, **ignored):
40
rval = pagetemplatefile.PageTemplateFile.pt_getContext(
41
self, args, options, **ignored)
43
rval.update({'here':Here(self.base, options)})