2
By VladDrac@irc.freenode.net/#turbogears
3
+ Some small modifications
6
from zope.pagetemplate import pagetemplatefile
11
def __init__(self, base):
14
def __getattr__(self, name):
15
# import pdb; pdb.set_trace()
16
tpl = PageTemplate(os.path.join(self.base, name))
19
class PageTemplate(pagetemplatefile.PageTemplateFile):
20
def __init__(self, name):
21
base = os.path.dirname(sys._getframe(1).f_globals["__file__"])
22
self.extra_context = {}
24
self.fullpath = os.path.join(base, self.name)
25
self.base = os.path.dirname(self.fullpath)
26
pagetemplatefile.PageTemplateFile.__init__(self, self.fullpath)
28
def render(self, extra_dict=None):
30
context = self.pt_getContext()
31
context.update(extra_dict)
32
return self.pt_render(context)
34
def add_context(self, d):
35
self.extra_context.update(d)
37
def pt_getContext(self, args=(), options={}, **ignored):
38
rval = pagetemplatefile.PageTemplateFile.pt_getContext(self, args, options, **ignored)
40
rval.update(self.extra_context)
41
rval.update({'here':Here(self.base), 'template':self})