For performance reason as suggested here, I am studying how to used the pr-compiled template.
I edit hello.tmpl in template directory as
#attr title = "This is my Template"
\${title} Hello \${who}!
then issued cheetah-compile.exe .\hello.tmpl and get the hello.py
In another python file runner.py , i have
!/usr/bin/env python
from Cheetah.Template import Template from template import hello def myMethod(): tmpl = hello.hello(searchList=[{'who' : 'world'}]) results = tmpl.respond() print tmpl
if name == 'main': myMethod()
But the outcome is
${title} Hello ${who}!
Debugging for a while, i found that inside hello.py
def respond(self, trans=None):
## CHEETAH: main method generated for this template
if (not trans and not self._CHEETAH__isBuffering and not callable(self.transaction)):
trans = self.transaction # is None unless self.awake() was called
if not trans:
trans = DummyTransaction()
it looks like the trans is None, so it goes to DummyTransaction, what did I miss here? Any suggestions to how to fix it?