1
"""Support for Zope Page Templates using the simpletal library."""
1
"TurboGears support for Zope Page Templates"
8
7
from simpletal import simpleTAL, simpleTALES
10
logging.getLogger("simpleTAL").setLevel(logging.INFO)
11
logging.getLogger("simpleTALES").setLevel(logging.INFO)
36
32
self.template.expandInline(context, s)
37
33
return s.getvalue()
39
def expand_into(self, f, **info):
35
def expand_(self, f, **info):
40
36
context = simpleTALES.Context(allowPythonPath=1)
41
37
for k, v in info.iteritems():
42
38
context.addGlobal(k, v)
47
43
return self.template.macros
50
def load_template(classname):
51
"""Searches for a template along the Python path.
53
Template files must end in ".pt" and be in legitimate packages.
54
Templates are automatically checked for changes and reloaded as
57
divider = classname.rfind(".")
59
package = classname[0:divider]
60
basename = classname[divider+1:]
62
raise ValueError, "All templates must be in a package"
64
tfile = pkg_resources.resource_filename(
65
package, "%s.%s" % (basename, "pt"))
46
class TurboZpt(object):
49
def __init__(self, extra_vars_func=None):
50
self.get_extra_vars = extra_vars_func
52
def load_template(self, classname, loadingSite=False):
53
"""Searches for a template along the Python path.
55
Template files must end in ".pt" and be in legitimate packages.
56
Templates are automatically checked for changes and reloaded as
59
divider = classname.rfind(".")
61
package = classname[0:divider]
62
basename = classname[divider+1:]
64
raise ValueError, "All templates must be in a package"
66
tfile = pkg_resources.resource_filename(
67
package, "%s.%s" % (basename, self.extension))