Note that there are some explanatory texts on larger screens.

plurals
  1. POCheetah pre-compiled template usage
    primarykey
    data
    text
    <p>For performance reason as suggested <a href="http://packages.python.org/Cheetah/recipes/precompiled.html" rel="nofollow noreferrer">here</a>, I am studying how to used the pr-compiled template.</p> <p>I edit <code>hello.tmpl</code> in template directory as</p> <pre><code>#attr title = "This is my Template" &lt;html&gt; &lt;head&gt; &lt;title&gt;\${title}&lt;/title&gt; &lt;/head&gt; &lt;body&gt; Hello \${who}! &lt;/body&gt; &lt;/html&gt; </code></pre> <p>then issued <code>cheetah-compile.exe .\hello.tmpl</code> and get the <code>hello.py</code></p> <p>In another python file <code>runner.py</code>, I have:</p> <pre><code>#!/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() </code></pre> <p>But the outcome is </p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;title&gt;${title}&lt;/title&gt; &lt;/head&gt; &lt;body&gt; Hello ${who}! &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Debugging for a while, I found that inside <code>hello.py</code>:</p> <pre><code>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() </code></pre> <p>it looks like the trans is None, so it goes to <code>DummyTransaction</code>, what did I miss here? Any suggestions to how to fix it?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload