summaryrefslogtreecommitdiff
path: root/www/html/api/Cheetah.Template.html
diff options
context:
space:
mode:
authorHyunjee Kim <hj0426.kim@samsung.com>2020-04-09 15:42:18 +0900
committerHyunjee Kim <hj0426.kim@samsung.com>2020-04-09 15:42:35 +0900
commitc50569b7f808f96205f682734e0ff7d751067d01 (patch)
treec81c1390de13ceff2e54bbd563101bed3029cd51 /www/html/api/Cheetah.Template.html
parent702ee4daf679b1079b199bb68589f25cb96aa27e (diff)
downloadpython3-Cheetah-c50569b7f808f96205f682734e0ff7d751067d01.tar.gz
python3-Cheetah-c50569b7f808f96205f682734e0ff7d751067d01.tar.bz2
python3-Cheetah-c50569b7f808f96205f682734e0ff7d751067d01.zip
Imported Upstream version 3.0.0upstream/3.0.0
Change-Id: I76de454a67549998787920c0b4a62fd3d29b1d8f Signed-off-by: Hyunjee Kim <hj0426.kim@samsung.com>
Diffstat (limited to 'www/html/api/Cheetah.Template.html')
-rw-r--r--www/html/api/Cheetah.Template.html800
1 files changed, 800 insertions, 0 deletions
diff --git a/www/html/api/Cheetah.Template.html b/www/html/api/Cheetah.Template.html
new file mode 100644
index 0000000..5800256
--- /dev/null
+++ b/www/html/api/Cheetah.Template.html
@@ -0,0 +1,800 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+ <head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+ <title>Cheetah.Template module &#8212; Cheetah3 - The Python-Powered Template Engine</title>
+
+ <link rel="stylesheet" href="../_static/sphinxdoc.css" type="text/css" />
+ <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
+
+ <script type="text/javascript">
+ var DOCUMENTATION_OPTIONS = {
+ URL_ROOT: '../',
+ VERSION: '3.0.0',
+ COLLAPSE_INDEX: false,
+ FILE_SUFFIX: '.html',
+ HAS_SOURCE: true,
+ SOURCELINK_SUFFIX: '.txt'
+ };
+ </script>
+ <script type="text/javascript" src="../_static/jquery.js"></script>
+ <script type="text/javascript" src="../_static/underscore.js"></script>
+ <script type="text/javascript" src="../_static/doctools.js"></script>
+ <link rel="index" title="Index" href="../genindex.html" />
+ <link rel="search" title="Search" href="../search.html" />
+ </head>
+ <body role="document">
+ <div class="related" role="navigation" aria-label="related navigation">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="../genindex.html" title="General Index"
+ accesskey="I">index</a></li>
+ <li class="right" >
+ <a href="../py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li class="nav-item nav-item-0"><a href="../index.html">Cheetah3 - The Python-Powered Template Engine</a> &#187;</li>
+ </ul>
+ </div>
+ <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
+ <div class="sphinxsidebarwrapper">
+ <div role="note" aria-label="source link">
+ <h3>This Page</h3>
+ <ul class="this-page-menu">
+ <li><a href="../_sources/api/Cheetah.Template.rst.txt"
+ rel="nofollow">Show Source</a></li>
+ </ul>
+ </div>
+<div id="searchbox" style="display: none" role="search">
+ <h3>Quick search</h3>
+ <form class="search" action="../search.html" method="get">
+ <div><input type="text" name="q" /></div>
+ <div><input type="submit" value="Go" /></div>
+ <input type="hidden" name="check_keywords" value="yes" />
+ <input type="hidden" name="area" value="default" />
+ </form>
+</div>
+<script type="text/javascript">$('#searchbox').show(0);</script>
+ </div>
+ </div>
+
+ <div class="document">
+ <div class="documentwrapper">
+ <div class="bodywrapper">
+ <div class="body" role="main">
+
+ <div class="section" id="module-Cheetah.Template">
+<span id="cheetah-template-module"></span><h1>Cheetah.Template module<a class="headerlink" href="#module-Cheetah.Template" title="Permalink to this headline">¶</a></h1>
+<p>Provides the core API for Cheetah.</p>
+<p>See the docstring in the Template class and the Users&#8217; Guide for more information</p>
+<dl class="class">
+<dt id="Cheetah.Template.CompileCacheItem">
+<em class="property">class </em><code class="descclassname">Cheetah.Template.</code><code class="descname">CompileCacheItem</code><a class="headerlink" href="#Cheetah.Template.CompileCacheItem" title="Permalink to this definition">¶</a></dt>
+<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
+</dd></dl>
+
+<dl class="exception">
+<dt id="Cheetah.Template.Error">
+<em class="property">exception </em><code class="descclassname">Cheetah.Template.</code><code class="descname">Error</code><a class="headerlink" href="#Cheetah.Template.Error" title="Permalink to this definition">¶</a></dt>
+<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">exceptions.Exception</span></code></p>
+</dd></dl>
+
+<dl class="exception">
+<dt id="Cheetah.Template.PreprocessError">
+<em class="property">exception </em><code class="descclassname">Cheetah.Template.</code><code class="descname">PreprocessError</code><a class="headerlink" href="#Cheetah.Template.PreprocessError" title="Permalink to this definition">¶</a></dt>
+<dd><p>Bases: <a class="reference internal" href="#Cheetah.Template.Error" title="Cheetah.Template.Error"><code class="xref py py-class docutils literal"><span class="pre">Cheetah.Template.Error</span></code></a></p>
+</dd></dl>
+
+<dl class="attribute">
+<dt id="Cheetah.Template.T">
+<code class="descclassname">Cheetah.Template.</code><code class="descname">T</code><a class="headerlink" href="#Cheetah.Template.T" title="Permalink to this definition">¶</a></dt>
+<dd><p>alias of <a class="reference internal" href="#Cheetah.Template.Template" title="Cheetah.Template.Template"><code class="xref py py-class docutils literal"><span class="pre">Template</span></code></a></p>
+</dd></dl>
+
+<dl class="class">
+<dt id="Cheetah.Template.Template">
+<em class="property">class </em><code class="descclassname">Cheetah.Template.</code><code class="descname">Template</code><span class="sig-paren">(</span><em>source=None</em>, <em>namespaces=None</em>, <em>searchList=None</em>, <em>file=None</em>, <em>filter='RawOrEncodedUnicode'</em>, <em>filtersLib=&lt;module 'Cheetah.Filters' from '/home/phd/current/projects/cheetah3/cheetah3/Cheetah/Filters.pyc'&gt;</em>, <em>errorCatcher=None</em>, <em>compilerSettings=Unspecified</em>, <em>_globalSetVars=None</em>, <em>_preBuiltSearchList=None</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template" title="Permalink to this definition">¶</a></dt>
+<dd><p>Bases: <a class="reference internal" href="Cheetah.Servlet.html#Cheetah.Servlet.Servlet" title="Cheetah.Servlet.Servlet"><code class="xref py py-class docutils literal"><span class="pre">Cheetah.Servlet.Servlet</span></code></a></p>
+<p>This class provides a) methods used by templates at runtime and b)
+methods for compiling Cheetah source code into template classes.</p>
+<p>This documentation assumes you already know Python and the basics of object
+oriented programming. If you don&#8217;t know Python, see the sections of the
+Cheetah Users&#8217; Guide for non-programmers. It also assumes you have read
+about Cheetah&#8217;s syntax in the Users&#8217; Guide.</p>
+<p>The following explains how to use Cheetah from within Python programs or via
+the interpreter. If you statically compile your templates on the command
+line using the &#8216;cheetah&#8217; script, this is not relevant to you. Statically
+compiled Cheetah template modules/classes (e.g. myTemplate.py:
+MyTemplateClasss) are just like any other Python module or class. Also note,
+most Python web frameworks (Webware, Aquarium, mod_python, Turbogears,
+CherryPy, Quixote, etc.) provide plugins that handle Cheetah compilation for
+you.</p>
+<p>There are several possible usage patterns:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="mi">1</span><span class="p">)</span> <span class="n">tclass</span> <span class="o">=</span> <span class="n">Template</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
+ <span class="n">t1</span> <span class="o">=</span> <span class="n">tclass</span><span class="p">()</span> <span class="c1"># or tclass(namespaces=[namespace,...])</span>
+ <span class="n">t2</span> <span class="o">=</span> <span class="n">tclass</span><span class="p">()</span> <span class="c1"># or tclass(namespaces=[namespace2,...])</span>
+ <span class="n">outputStr</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">t1</span><span class="p">)</span> <span class="c1"># or outputStr = t1.aMethodYouDefined()</span>
+
+ <span class="n">Template</span><span class="o">.</span><span class="n">compile</span> <span class="n">provides</span> <span class="n">a</span> <span class="n">rich</span> <span class="ow">and</span> <span class="n">very</span> <span class="n">flexible</span> <span class="n">API</span> <span class="n">via</span> <span class="n">its</span>
+ <span class="n">optional</span> <span class="n">arguments</span> <span class="n">so</span> <span class="n">there</span> <span class="n">are</span> <span class="n">many</span> <span class="n">possible</span> <span class="n">variations</span> <span class="n">of</span> <span class="n">this</span>
+ <span class="n">pattern</span><span class="o">.</span> <span class="n">One</span> <span class="n">example</span> <span class="ow">is</span><span class="p">:</span>
+ <span class="n">tclass</span> <span class="o">=</span> <span class="n">Template</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s1">&#39;hello $name from $caller&#39;</span><span class="p">,</span> <span class="n">baseclass</span><span class="o">=</span><span class="nb">dict</span><span class="p">)</span>
+ <span class="nb">print</span><span class="p">(</span><span class="n">tclass</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s1">&#39;world&#39;</span><span class="p">,</span> <span class="n">caller</span><span class="o">=</span><span class="s1">&#39;me&#39;</span><span class="p">))</span>
+ <span class="n">See</span> <span class="n">the</span> <span class="n">Template</span><span class="o">.</span><span class="n">compile</span><span class="p">()</span> <span class="n">docstring</span> <span class="k">for</span> <span class="n">more</span> <span class="n">details</span><span class="o">.</span>
+
+<span class="mi">2</span><span class="p">)</span> <span class="n">tmplInstance</span> <span class="o">=</span> <span class="n">Template</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
+ <span class="c1"># or Template(src, namespaces=[namespace,...])</span>
+ <span class="n">outputStr</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">tmplInstance</span><span class="p">)</span> <span class="c1"># or outputStr = tmplInstance.aMethodYouDefined(...args...)</span>
+</pre></div>
+</div>
+<p>Notes on the usage patterns:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">usage</span> <span class="n">pattern</span> <span class="mi">1</span><span class="p">)</span>
+ <span class="n">This</span> <span class="ow">is</span> <span class="n">the</span> <span class="n">most</span> <span class="n">flexible</span><span class="p">,</span> <span class="n">but</span> <span class="n">it</span> <span class="ow">is</span> <span class="n">slightly</span> <span class="n">more</span> <span class="n">verbose</span> <span class="n">unless</span> <span class="n">you</span>
+ <span class="n">write</span> <span class="n">a</span> <span class="n">wrapper</span> <span class="n">function</span> <span class="n">to</span> <span class="n">hide</span> <span class="n">the</span> <span class="n">plumbing</span><span class="o">.</span> <span class="n">Under</span> <span class="n">the</span> <span class="n">hood</span><span class="p">,</span> <span class="nb">all</span>
+ <span class="n">other</span> <span class="n">usage</span> <span class="n">patterns</span> <span class="n">are</span> <span class="n">based</span> <span class="n">on</span> <span class="n">this</span> <span class="n">approach</span><span class="o">.</span> <span class="n">Templates</span> <span class="n">compiled</span>
+ <span class="n">this</span> <span class="n">way</span> <span class="n">can</span> <span class="c1">#extend (subclass) any Python baseclass: old-style or</span>
+ <span class="n">new</span><span class="o">-</span><span class="n">style</span> <span class="p">(</span><span class="n">based</span> <span class="n">on</span> <span class="nb">object</span> <span class="ow">or</span> <span class="n">a</span> <span class="n">builtin</span> <span class="nb">type</span><span class="p">)</span><span class="o">.</span>
+
+<span class="n">usage</span> <span class="n">pattern</span> <span class="mi">2</span><span class="p">)</span>
+ <span class="n">This</span> <span class="n">was</span> <span class="n">Cheetah</span><span class="s1">&#39;s original usage pattern. It returns an instance,</span>
+ <span class="n">but</span> <span class="n">you</span> <span class="n">can</span> <span class="n">still</span> <span class="n">access</span> <span class="n">the</span> <span class="n">generated</span> <span class="k">class</span> <span class="nc">via</span>
+ <span class="n">tmplInstance</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span> <span class="n">If</span> <span class="n">you</span> <span class="n">want</span> <span class="n">to</span> <span class="n">use</span> <span class="n">several</span> <span class="n">different</span>
+ <span class="n">namespace</span> <span class="s1">&#39;searchLists&#39;</span> <span class="k">with</span> <span class="n">a</span> <span class="n">single</span> <span class="n">template</span> <span class="n">source</span> <span class="n">definition</span><span class="p">,</span>
+ <span class="n">you</span><span class="s1">&#39;re better off with Template.compile (1).</span>
+
+ <span class="n">Limitations</span> <span class="p">(</span><span class="n">use</span> <span class="n">pattern</span> <span class="mi">1</span> <span class="n">instead</span><span class="p">)::</span>
+
+ <span class="o">-</span> <span class="n">Templates</span> <span class="n">compiled</span> <span class="n">this</span> <span class="n">way</span> <span class="n">can</span> <span class="n">only</span> <span class="c1">#extend subclasses of the</span>
+ <span class="n">new</span><span class="o">-</span><span class="n">style</span> <span class="s1">&#39;object&#39;</span> <span class="n">baseclass</span><span class="o">.</span> <span class="n">Cheetah</span><span class="o">.</span><span class="n">Template</span> <span class="ow">is</span> <span class="n">a</span> <span class="n">subclass</span> <span class="n">of</span>
+ <span class="s1">&#39;object&#39;</span><span class="o">.</span> <span class="n">You</span> <span class="n">also</span> <span class="n">can</span> <span class="ow">not</span> <span class="c1">#extend dict, list, or other builtin</span>
+ <span class="n">types</span><span class="o">.</span>
+ <span class="o">-</span> <span class="n">If</span> <span class="n">your</span> <span class="n">template</span> <span class="n">baseclass</span><span class="s1">&#39; __init__ constructor expects args there</span>
+ <span class="ow">is</span> <span class="n">currently</span> <span class="n">no</span> <span class="n">way</span> <span class="n">to</span> <span class="k">pass</span> <span class="n">them</span> <span class="ow">in</span><span class="o">.</span>
+</pre></div>
+</div>
+<p>If you need to subclass a dynamically compiled Cheetah class, do something like this:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">Cheetah.Template</span> <span class="k">import</span> <span class="n">Template</span>
+<span class="n">T1</span> <span class="o">=</span> <span class="n">Template</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s1">&#39;$meth1 #def meth1: this is meth1 in T1&#39;</span><span class="p">)</span>
+<span class="n">T2</span> <span class="o">=</span> <span class="n">Template</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="s1">&#39;#implements meth1</span><span class="se">\n</span><span class="s1">this is meth1 redefined in T2&#39;</span><span class="p">,</span> <span class="n">baseclass</span><span class="o">=</span><span class="n">T1</span><span class="p">)</span>
+<span class="nb">print</span><span class="p">(</span><span class="n">T1</span><span class="p">,</span> <span class="n">T1</span><span class="p">())</span>
+<span class="nb">print</span><span class="p">(</span><span class="n">T2</span><span class="p">,</span> <span class="n">T2</span><span class="p">())</span>
+</pre></div>
+</div>
+<p>Note about class and instance attribute names:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Attributes</span> <span class="n">used</span> <span class="n">by</span> <span class="n">Cheetah</span> <span class="n">have</span> <span class="n">a</span> <span class="n">special</span> <span class="n">prefix</span> <span class="n">to</span> <span class="n">avoid</span> <span class="n">confusion</span> <span class="k">with</span>
+<span class="n">the</span> <span class="n">attributes</span> <span class="n">of</span> <span class="n">the</span> <span class="n">templates</span> <span class="n">themselves</span> <span class="ow">or</span> <span class="n">those</span> <span class="n">of</span> <span class="n">template</span>
+<span class="n">baseclasses</span><span class="o">.</span>
+
+<span class="n">Class</span> <span class="n">attributes</span> <span class="n">which</span> <span class="n">are</span> <span class="n">used</span> <span class="ow">in</span> <span class="k">class</span> <span class="nc">methods</span> <span class="n">look</span> <span class="n">like</span> <span class="n">this</span><span class="p">::</span>
+
+ <span class="n">klass</span><span class="o">.</span><span class="n">_CHEETAH_useCompilationCache</span> <span class="p">(</span><span class="n">_CHEETAH_xxx</span><span class="p">)</span>
+
+<span class="n">Instance</span> <span class="n">attributes</span> <span class="n">look</span> <span class="n">like</span> <span class="n">this</span><span class="p">::</span>
+
+ <span class="n">klass</span><span class="o">.</span><span class="n">_CHEETAH__globalSetVars</span> <span class="p">(</span><span class="n">_CHEETAH__xxx</span> <span class="k">with</span> <span class="mi">2</span> <span class="n">underscores</span><span class="p">)</span>
+</pre></div>
+</div>
+<dl class="exception">
+<dt id="Cheetah.Template.Template.NonNumericInputError">
+<em class="property">exception </em><code class="descname">NonNumericInputError</code><a class="headerlink" href="#Cheetah.Template.Template.NonNumericInputError" title="Permalink to this definition">¶</a></dt>
+<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">exceptions.ValueError</span></code></p>
+</dd></dl>
+
+<dl class="attribute">
+<dt id="Cheetah.Template.Template.Reserved_SearchList">
+<code class="descname">Reserved_SearchList</code><em class="property"> = set(['respond', '_CHEETAH_preprocessors', '__module__', '__format__', '_CHEETAH_defaultMainMethodNameForTemplates', '_CHEETAH_keepRefToGeneratedCode', 'serverSidePath', 'searchList', '__str__', '__getattribute__', '_getTemplateAPIClassForIncludeDirectiveCompilation', 'transaction', '_CHEETAH_defaultModuleNameForTemplates', '_CHEETAH_cacheCompilationResults', 'application', 'sleep', 'getCacheRegions', 'shutdown', 'hasVar', '__dict__', '__sizeof__', '__weakref__', '_createCacheRegion', '_CHEETAH_generatedModuleCode', 'runAsMainProgram', 'getCacheRegion', '__setattr__', '__reduce_ex__', '__new__', '__delattr__', '_normalizePreprocessorSettings', '_CHEETAH_compilerInstance', 'errorCatcher', '_CHEETAH_requiredCheetahClassMethods', '__class__', '_CHEETAH_useCompilationCache', '_updateSettingsWithPreprocessTokens', '_CHEETAH_cacheStoreIdPrefix', 'session', '_CHEETAH_defaultMainMethodName', '_normalizePreprocessorArg', 'getVar', '_compile', '_CHEETAH_cacheDirForModuleFiles', '__doc__', '_handleCheetahInclude', '_CHEETAH_compileLock', '_CHEETAH_defaultClassNameForTemplates', '_CHEETAH_requiredCheetahMethods', '_CHEETAH_compilerSettings', 'generatedClassCode', 'i18n', '_addCheetahPlumbingCodeToClass', '_CHEETAH_defaultBaseclassForTemplates', '_CHEETAH_defaultPreprocessorClass', '__hash__', 'webInput', '__subclasshook__', '_CHEETAH_requiredCheetahClassAttributes', '_CHEETAH_compileCache', '_CHEETAH_cacheStoreClass', '__reduce__', 'subclass', '_CHEETAH_cacheRegionClass', '_CHEETAH_cacheStore', '_initCheetahInstance', 'generatedModuleCode', '_CHEETAH_cacheModuleFilesForTracebacks', '_getCacheStore', '_getCacheStoreIdPrefix', 'refreshCache', '_getCompilerClass', 'request', 'getFileContents', 'compile', '_CHEETAH_compilerClass', '_preprocessSource', '_CHEETAH_defaultModuleGlobalsForTemplates', '__repr__', '__init__', 'NonNumericInputError', '_getCompilerSettings', 'varExists'])</em><a class="headerlink" href="#Cheetah.Template.Template.Reserved_SearchList" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="classmethod">
+<dt id="Cheetah.Template.Template.compile">
+<em class="property">classmethod </em><code class="descname">compile</code><span class="sig-paren">(</span><em>klass</em>, <em>source=None</em>, <em>file=None</em>, <em>returnAClass=True</em>, <em>compilerSettings=Unspecified</em>, <em>compilerClass=Unspecified</em>, <em>moduleName=None</em>, <em>className=Unspecified</em>, <em>mainMethodName=Unspecified</em>, <em>baseclass=Unspecified</em>, <em>moduleGlobals=Unspecified</em>, <em>cacheCompilationResults=Unspecified</em>, <em>useCache=Unspecified</em>, <em>preprocessors=Unspecified</em>, <em>cacheModuleFilesForTracebacks=Unspecified</em>, <em>cacheDirForModuleFiles=Unspecified</em>, <em>commandlineopts=None</em>, <em>keepRefToGeneratedCode=Unspecified</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.compile" title="Permalink to this definition">¶</a></dt>
+<dd><p>The core API for compiling Cheetah source code into template classes.</p>
+<p>This class method compiles Cheetah source code and returns a python
+class. You then create template instances using that class. All
+Cheetah&#8217;s other compilation API&#8217;s use this method under the hood.</p>
+<p>Internally, this method a) parses the Cheetah source code and generates
+Python code defining a module with a single class in it, b) dynamically
+creates a module object with a unique name, c) execs the generated code
+in that module&#8217;s namespace then inserts the module into sys.modules, and
+d) returns a reference to the generated class. If you want to get the
+generated python source code instead, pass the argument
+returnAClass=False.</p>
+<p>It caches generated code and classes. See the descriptions of the
+arguments&#8217;cacheCompilationResults&#8217; and &#8216;useCache&#8217; for details. This
+doesn&#8217;t mean that templates will automatically recompile themselves when
+the source file changes. Rather, if you call Template.compile(src) or
+Template.compile(file=path) repeatedly it will attempt to return a
+cached class definition instead of recompiling.</p>
+<p>Hooks are provided template source preprocessing. See the notes on the
+&#8216;preprocessors&#8217; arg.</p>
+<p>If you are an advanced user and need to customize the way Cheetah parses
+source code or outputs Python code, you should check out the
+compilerSettings argument.</p>
+<p>Arguments:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span>You must provide either a &#39;source&#39; or &#39;file&#39; arg, but not both::
+
+ - source (string or None)
+ - file (string path, file-like object, or None)
+
+The rest of the arguments are strictly optional. All but the first
+have defaults in attributes of the Template class which can be
+overridden in subclasses of this class. Working with most of these is
+an advanced topic.
+
+::
+
+ - returnAClass=True
+ If false, return the generated module code rather than a class.
+
+ - compilerSettings (a dict)
+ Default: Template._CHEETAH_compilerSettings=None
+
+ a dictionary of settings to override those defined in
+ DEFAULT_COMPILER_SETTINGS. These can also be overridden in your
+ template source code with the #compiler or #compiler-settings
+ directives.
+
+ - compilerClass (a class)
+ Default: Template._CHEETAH_compilerClass=Cheetah.Compiler.Compiler
+
+ a subclass of Cheetah.Compiler.Compiler. Mucking with this is a
+ very advanced topic.
+
+ - moduleName (a string)
+ Default:
+ Template._CHEETAH_defaultModuleNameForTemplates
+ =&#39;DynamicallyCompiledCheetahTemplate&#39;
+
+ What to name the generated Python module. If the provided value is
+ None and a file arg was given, the moduleName is created from the
+ file path. In all cases if the moduleName provided is already in
+ sys.modules it is passed through a filter that generates a unique
+ variant of the name.
+
+
+ - className (a string)
+ Default: Template._CHEETAH_defaultClassNameForTemplates=None
+
+ What to name the generated Python class. If the provided value is
+ None, the moduleName is use as the class name.
+
+ - mainMethodName (a string)
+ Default:
+ Template._CHEETAH_defaultMainMethodNameForTemplates
+ =None (and thus DEFAULT_COMPILER_SETTINGS[&#39;mainMethodName&#39;])
+
+ What to name the main output generating method in the compiled
+ template class.
+
+ - baseclass (a string or a class)
+ Default: Template._CHEETAH_defaultBaseclassForTemplates=None
+
+ Specifies the baseclass for the template without manually
+ including an #extends directive in the source. The #extends
+ directive trumps this arg.
+
+ If the provided value is a string you must make sure that a class
+ reference by that name is available to your template, either by
+ using an #import directive or by providing it in the arg
+ &#39;moduleGlobals&#39;.
+
+ If the provided value is a class, Cheetah will handle all the
+ details for you.
+
+ - moduleGlobals (a dict)
+ Default: Template._CHEETAH_defaultModuleGlobalsForTemplates=None
+
+ A dict of vars that will be added to the global namespace of the
+ module the generated code is executed in, prior to the execution
+ of that code. This should be Python values, not code strings!
+
+ - cacheCompilationResults (True/False)
+ Default: Template._CHEETAH_cacheCompilationResults=True
+
+ Tells Cheetah to cache the generated code and classes so that they
+ can be reused if Template.compile() is called multiple times with
+ the same source and options.
+
+ - useCache (True/False)
+ Default: Template._CHEETAH_useCompilationCache=True
+
+ Should the compilation cache be used? If True and a previous
+ compilation created a cached template class with the same source
+ code, compiler settings and other options, the cached template
+ class will be returned.
+
+ - cacheModuleFilesForTracebacks (True/False)
+ Default: Template._CHEETAH_cacheModuleFilesForTracebacks=False
+
+ In earlier versions of Cheetah tracebacks from exceptions that
+ were raised inside dynamically compiled Cheetah templates were
+ opaque because Python didn&#39;t have access to a python source file
+ to use in the traceback:
+
+ File &quot;xxxx.py&quot;, line 192, in getTextiledContent
+ content = str(template(searchList=searchList))
+ File &quot;cheetah_yyyy.py&quot;, line 202, in __str__
+ File &quot;cheetah_yyyy.py&quot;, line 187, in respond
+ File &quot;cheetah_yyyy.py&quot;, line 139, in writeBody
+ ZeroDivisionError: integer division or modulo by zero
+
+ It is now possible to keep those files in a cache dir and allow
+ Python to include the actual source lines in tracebacks and makes
+ them much easier to understand:
+
+ File &quot;xxxx.py&quot;, line 192, in getTextiledContent
+ content = str(template(searchList=searchList))
+ File &quot;/tmp/CheetahCacheDir/cheetah_yyyy.py&quot;, line 202, in __str__
+ def __str__(self): return self.respond()
+ File &quot;/tmp/CheetahCacheDir/cheetah_yyyy.py&quot;, line 187, in respond
+ self.writeBody(trans=trans)
+ File &quot;/tmp/CheetahCacheDir/cheetah_yyyy.py&quot;, line 139, in writeBody
+ __v = 0/0 # $(0/0)
+ ZeroDivisionError: integer division or modulo by zero
+
+ - cacheDirForModuleFiles (a string representing a dir path)
+ Default: Template._CHEETAH_cacheDirForModuleFiles=None
+
+ See notes on cacheModuleFilesForTracebacks.
+
+ - preprocessors
+ Default: Template._CHEETAH_preprocessors=None
+
+ ** THIS IS A VERY ADVANCED TOPIC **
+
+ These are used to transform the source code prior to compilation.
+ They provide a way to use Cheetah as a code generator for Cheetah
+ code. In other words, you use one Cheetah template to output the
+ source code for another Cheetah template.
+
+ The major expected use cases are:
+
+ a) &#39;compile-time caching&#39; aka &#39;partial template binding&#39;,
+ wherein an intermediate Cheetah template is used to output
+ the source for the final Cheetah template. The intermediate
+ template is a mix of a modified Cheetah syntax (the
+ &#39;preprocess syntax&#39;) and standard Cheetah syntax. The
+ preprocessor syntax is executed at compile time and outputs
+ Cheetah code which is then compiled in turn. This approach
+ allows one to completely soft-code all the elements in the
+ template which are subject to change yet have it compile to
+ extremely efficient Python code with everything but the
+ elements that must be variable at runtime (per browser
+ request, etc.) compiled as static strings. Examples of this
+ usage pattern will be added to the Cheetah Users&#39; Guide.
+
+ The&#39;preprocess syntax&#39; is just Cheetah&#39;s standard one with
+ alternatives for the $ and # tokens:
+
+ e.g. &#39;@&#39; and &#39;%&#39; for code like this
+ @aPreprocessVar $aRuntimeVar
+ %if aCompileTimeCondition then yyy else zzz
+ %% preprocessor comment
+
+ #if aRunTimeCondition then aaa else bbb
+ ## normal comment
+ $aRuntimeVar
+
+ b) adding #import and #extends directives dynamically based on
+ the source
+
+ If preprocessors are provided, Cheetah pipes the source code
+ through each one in the order provided. Each preprocessor should
+ accept the args (source, file) and should return a tuple (source,
+ file).
+
+ The argument value should be a list, but a single non-list value
+ is acceptable and will automatically be converted into a list.
+ Each item in the list will be passed through
+ Template._normalizePreprocessor(). The items should either match
+ one of the following forms:
+
+ - an object with a .preprocess(source, file) method
+ - a callable with the following signature:
+ source, file = f(source, file)
+
+ or one of the forms below:
+
+ - a single string denoting the 2 &#39;tokens&#39; for the preprocess
+ syntax. The tokens should be in the order (placeholderToken,
+ directiveToken) and should separated with a space:
+ e.g. &#39;@ %&#39;
+ klass = Template.compile(src, preprocessors=&#39;@ %&#39;)
+ # or
+ klass = Template.compile(src, preprocessors=[&#39;@ %&#39;])
+
+ - a dict with the following keys or an object with the
+ following attributes (all are optional, but nothing will
+ happen if you don&#39;t provide at least one):
+ - tokens: same as the single string described above. You can
+ also provide a tuple of 2 strings.
+ - searchList: the searchList used for preprocess $placeholders
+ - compilerSettings: used in the compilation of the intermediate
+ template
+ - templateAPIClass: an optional subclass of `Template`
+ - outputTransformer: a simple hook for passing in a callable
+ which can do further transformations of the preprocessor
+ output, or do something else like debug logging. The
+ default is str().
+ + any keyword arguments to Template.compile which you want to
+ provide for the compilation of the intermediate template.
+
+ klass = Template.compile(src,
+ preprocessors=[ dict(tokens=&#39;@ %&#39;, searchList=[...]) ] )
+</pre></div>
+</div>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.errorCatcher">
+<code class="descname">errorCatcher</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.errorCatcher" title="Permalink to this definition">¶</a></dt>
+<dd><p>Return a reference to the current errorCatcher</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.generatedClassCode">
+<code class="descname">generatedClassCode</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.generatedClassCode" title="Permalink to this definition">¶</a></dt>
+<dd><p>Return the class code the compiler generated, or None if no
+compilation took place.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.generatedModuleCode">
+<code class="descname">generatedModuleCode</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.generatedModuleCode" title="Permalink to this definition">¶</a></dt>
+<dd><p>Return the module code the compiler generated, or None if no
+compilation took place.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.getCacheRegion">
+<code class="descname">getCacheRegion</code><span class="sig-paren">(</span><em>regionID</em>, <em>cacheInfo=None</em>, <em>create=True</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.getCacheRegion" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.getCacheRegions">
+<code class="descname">getCacheRegions</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.getCacheRegions" title="Permalink to this definition">¶</a></dt>
+<dd><p>Returns a dictionary of the &#8216;cache regions&#8217; initialized in a
+template.</p>
+<p>Each #cache directive block or $*cachedPlaceholder is a separate &#8216;cache
+region&#8217;.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.getFileContents">
+<code class="descname">getFileContents</code><span class="sig-paren">(</span><em>path</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.getFileContents" title="Permalink to this definition">¶</a></dt>
+<dd><p>A hook for getting the contents of a file. The default
+implementation just uses the Python open() function to load local files.
+This method could be reimplemented to allow reading of remote files via
+various protocols, as PHP allows with its &#8216;URL fopen wrapper&#8217;</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.getVar">
+<code class="descname">getVar</code><span class="sig-paren">(</span><em>varName</em>, <em>default=Unspecified</em>, <em>autoCall=True</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.getVar" title="Permalink to this definition">¶</a></dt>
+<dd><p>Get a variable from the searchList. If the variable can&#8217;t be found
+in the searchList, it returns the default value if one was given, or
+raises NameMapper.NotFound.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.hasVar">
+<code class="descname">hasVar</code><span class="sig-paren">(</span><em>varName</em>, <em>autoCall=True</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.hasVar" title="Permalink to this definition">¶</a></dt>
+<dd><p>Test if a variable name exists in the searchList.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.i18n">
+<code class="descname">i18n</code><span class="sig-paren">(</span><em>message</em>, <em>plural=None</em>, <em>n=None</em>, <em>id=None</em>, <em>domain=None</em>, <em>source=None</em>, <em>target=None</em>, <em>comment=None</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.i18n" title="Permalink to this definition">¶</a></dt>
+<dd><p>This is just a stub at this time.</p>
+<blockquote>
+<div><div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">plural</span> <span class="o">=</span> <span class="n">the</span> <span class="n">plural</span> <span class="n">form</span> <span class="n">of</span> <span class="n">the</span> <span class="n">message</span>
+<span class="n">n</span> <span class="o">=</span> <span class="n">a</span> <span class="n">sized</span> <span class="n">argument</span> <span class="n">to</span> <span class="n">distinguish</span> <span class="n">between</span> <span class="n">single</span> <span class="ow">and</span> <span class="n">plural</span> <span class="n">forms</span>
+<span class="nb">id</span> <span class="o">=</span> <span class="n">msgid</span> <span class="ow">in</span> <span class="n">the</span> <span class="n">translation</span> <span class="n">catalog</span>
+<span class="n">domain</span> <span class="o">=</span> <span class="n">translation</span> <span class="n">domain</span>
+<span class="n">source</span> <span class="o">=</span> <span class="n">source</span> <span class="n">lang</span>
+<span class="n">target</span> <span class="o">=</span> <span class="n">a</span> <span class="n">specific</span> <span class="n">target</span> <span class="n">lang</span>
+<span class="n">comment</span> <span class="o">=</span> <span class="n">a</span> <span class="n">comment</span> <span class="n">to</span> <span class="n">the</span> <span class="n">translation</span> <span class="n">team</span>
+</pre></div>
+</div>
+</div></blockquote>
+<p>See the following for some ideas
+<a class="reference external" href="http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/ZPTInternationalizationSupport">http://www.zope.org/DevHome/Wikis/DevSite/Projects/ComponentArchitecture/ZPTInternationalizationSupport</a></p>
+<p>Other notes:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">-</span> <span class="n">There</span> <span class="ow">is</span> <span class="n">no</span> <span class="n">need</span> <span class="n">to</span> <span class="n">replicate</span> <span class="n">the</span> <span class="n">i18n</span><span class="p">:</span><span class="n">name</span> <span class="n">attribute</span> <span class="kn">from</span> <span class="nn">plone</span> <span class="o">/</span> <span class="n">PTL</span><span class="p">,</span>
+ <span class="k">as</span> <span class="n">cheetah</span> <span class="n">placeholders</span> <span class="n">serve</span> <span class="n">the</span> <span class="n">same</span> <span class="n">purpose</span>
+</pre></div>
+</div>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.refreshCache">
+<code class="descname">refreshCache</code><span class="sig-paren">(</span><em>cacheRegionId=None</em>, <em>cacheItemId=None</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.refreshCache" title="Permalink to this definition">¶</a></dt>
+<dd><p>Refresh a cache region or a specific cache item within a region.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.runAsMainProgram">
+<code class="descname">runAsMainProgram</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.runAsMainProgram" title="Permalink to this definition">¶</a></dt>
+<dd><p>Allows the Template to function as a standalone command-line program
+for static page generation.</p>
+<p>Type &#8216;python yourtemplate.py &#8211;help to see what it&#8217;s capabable of.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.searchList">
+<code class="descname">searchList</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.searchList" title="Permalink to this definition">¶</a></dt>
+<dd><p>Return a reference to the searchlist</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.shutdown">
+<code class="descname">shutdown</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.shutdown" title="Permalink to this definition">¶</a></dt>
+<dd><p>Break reference cycles before discarding a servlet.</p>
+</dd></dl>
+
+<dl class="classmethod">
+<dt id="Cheetah.Template.Template.subclass">
+<em class="property">classmethod </em><code class="descname">subclass</code><span class="sig-paren">(</span><em>klass</em>, <em>*args</em>, <em>**kws</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.subclass" title="Permalink to this definition">¶</a></dt>
+<dd><p>Takes the same args as the .compile() classmethod and returns a
+template that is a subclass of the template this method is called from.</p>
+<p>T1 = Template.compile(&#8216;foo - $meth1 - barn#def meth1: this is T1.meth1&#8217;)
+T2 = T1.subclass(&#8216;#implements meth1n this is T2.meth1&#8217;)</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.varExists">
+<code class="descname">varExists</code><span class="sig-paren">(</span><em>varName</em>, <em>autoCall=True</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.varExists" title="Permalink to this definition">¶</a></dt>
+<dd><p>Test if a variable name exists in the searchList.</p>
+</dd></dl>
+
+<dl class="method">
+<dt id="Cheetah.Template.Template.webInput">
+<code class="descname">webInput</code><span class="sig-paren">(</span><em>names</em>, <em>namesMulti=()</em>, <em>default=''</em>, <em>src='f'</em>, <em>defaultInt=0</em>, <em>defaultFloat=0.0</em>, <em>badInt=0</em>, <em>badFloat=0.0</em>, <em>debug=False</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.Template.webInput" title="Permalink to this definition">¶</a></dt>
+<dd><p>Method for importing web transaction variables in bulk.</p>
+<p>This works for GET/POST fields both in Webware servlets and in CGI
+scripts, and for cookies and session variables in Webware servlets. If
+you try to read a cookie or session variable in a CGI script, you&#8217;ll get
+a RuntimeError. &#8216;In a CGI script&#8217; here means &#8216;not running as a Webware
+servlet&#8217;. If the CGI environment is not properly set up, Cheetah will
+act like there&#8217;s no input.</p>
+<p>The public method provided is:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">webInput</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">names</span><span class="p">,</span> <span class="n">namesMulti</span><span class="o">=</span><span class="p">(),</span> <span class="n">default</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">src</span><span class="o">=</span><span class="s1">&#39;f&#39;</span><span class="p">,</span>
+ <span class="n">defaultInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">defaultFloat</span><span class="o">=</span><span class="mf">0.00</span><span class="p">,</span> <span class="n">badInt</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">badFloat</span><span class="o">=</span><span class="mf">0.00</span><span class="p">,</span> <span class="n">debug</span><span class="o">=</span><span class="kc">False</span><span class="p">):</span>
+</pre></div>
+</div>
+<p>This method places the specified GET/POST fields, cookies or session
+variables into a dictionary, which is both returned and put at the
+beginning of the searchList. It handles:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">*</span> <span class="n">single</span> <span class="n">vs</span> <span class="n">multiple</span> <span class="n">values</span>
+<span class="o">*</span> <span class="n">conversion</span> <span class="n">to</span> <span class="n">integer</span> <span class="ow">or</span> <span class="nb">float</span> <span class="k">for</span> <span class="n">specified</span> <span class="n">names</span>
+<span class="o">*</span> <span class="n">default</span> <span class="n">values</span><span class="o">/</span><span class="n">exceptions</span> <span class="k">for</span> <span class="n">missing</span> <span class="ow">or</span> <span class="n">bad</span> <span class="n">values</span>
+<span class="o">*</span> <span class="n">printing</span> <span class="n">a</span> <span class="n">snapshot</span> <span class="n">of</span> <span class="nb">all</span> <span class="n">values</span> <span class="n">retrieved</span> <span class="k">for</span> <span class="n">debugging</span>
+</pre></div>
+</div>
+<p>All the &#8216;default*&#8217; and &#8216;bad*&#8217; arguments have &#8216;use or raise&#8217; behavior,
+meaning that if they&#8217;re a subclass of Exception, they&#8217;re raised. If
+they&#8217;re anything else, that value is substituted for the missing/bad
+value.</p>
+<p>The simplest usage is:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span>#silent $webInput([&#39;choice&#39;])
+$choice
+
+dic = self.webInput([&#39;choice&#39;])
+write(dic[&#39;choice&#39;])
+</pre></div>
+</div>
+<p>Both these examples retrieves the GET/POST field &#8216;choice&#8217; and print it.
+If you leave off the&#8217;#silent&#8217;, all the values would be printed too. But
+a better way to preview the values is:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="c1">#silent $webInput([&#39;name&#39;], $debug=1)</span>
+</pre></div>
+</div>
+<p>because this pretty-prints all the values inside HTML &lt;PRE&gt; tags.</p>
+<p>** KLUDGE: &#8216;debug&#8217; is supposed to insert into the template output, but it
+wasn&#8217;t working so I changed it to a&#8217;print&#8217; statement. So the debugging
+output will appear wherever standard output is pointed, whether at the
+terminal, in a Webware log file, or whatever. ***</p>
+<p>Since we didn&#8217;t specify any coversions, the value is a string. It&#8217;s a
+&#8216;single&#8217; value because we specified it in &#8216;names&#8217; rather than
+&#8216;namesMulti&#8217;. Single values work like this:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">*</span> <span class="n">If</span> <span class="n">one</span> <span class="n">value</span> <span class="ow">is</span> <span class="n">found</span><span class="p">,</span> <span class="n">take</span> <span class="n">it</span><span class="o">.</span>
+<span class="o">*</span> <span class="n">If</span> <span class="n">several</span> <span class="n">values</span> <span class="n">are</span> <span class="n">found</span><span class="p">,</span> <span class="n">choose</span> <span class="n">one</span> <span class="n">arbitrarily</span> <span class="ow">and</span> <span class="n">ignore</span> <span class="n">the</span> <span class="n">rest</span><span class="o">.</span>
+<span class="o">*</span> <span class="n">If</span> <span class="n">no</span> <span class="n">values</span> <span class="n">are</span> <span class="n">found</span><span class="p">,</span> <span class="n">use</span> <span class="ow">or</span> <span class="k">raise</span> <span class="n">the</span> <span class="n">appropriate</span> <span class="s1">&#39;default*&#39;</span> <span class="n">value</span><span class="o">.</span>
+</pre></div>
+</div>
+<p>Multi values work like this:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="o">*</span> <span class="n">If</span> <span class="n">one</span> <span class="n">value</span> <span class="ow">is</span> <span class="n">found</span><span class="p">,</span> <span class="n">put</span> <span class="n">it</span> <span class="ow">in</span> <span class="n">a</span> <span class="nb">list</span><span class="o">.</span>
+<span class="o">*</span> <span class="n">If</span> <span class="n">several</span> <span class="n">values</span> <span class="n">are</span> <span class="n">found</span><span class="p">,</span> <span class="n">leave</span> <span class="n">them</span> <span class="ow">in</span> <span class="n">a</span> <span class="nb">list</span><span class="o">.</span>
+<span class="o">*</span> <span class="n">If</span> <span class="n">no</span> <span class="n">values</span> <span class="n">are</span> <span class="n">found</span><span class="p">,</span> <span class="n">use</span> <span class="n">the</span> <span class="n">empty</span> <span class="nb">list</span> <span class="p">([])</span><span class="o">.</span> <span class="n">The</span> <span class="s1">&#39;default*&#39;</span>
+ <span class="n">arguments</span> <span class="n">are</span> <span class="o">*</span><span class="ow">not</span><span class="o">*</span> <span class="n">consulted</span> <span class="ow">in</span> <span class="n">this</span> <span class="n">case</span><span class="o">.</span>
+</pre></div>
+</div>
+<p>Example: assume &#8216;days&#8217; came from a set of checkboxes or a multiple combo
+box on a form, and the user chose&#8217;Monday&#8217;, &#8216;Tuesday&#8217; and &#8216;Thursday&#8217;:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span>#silent $webInput([], [&#39;days&#39;])
+The days you chose are: #slurp
+#for $day in $days
+$day #slurp
+#end for
+
+dic = self.webInput([], [&#39;days&#39;])
+write(&#39;The days you chose are: &#39;)
+for day in dic[&#39;days&#39;]:
+ write(day + &#39; &#39;)
+</pre></div>
+</div>
+<p>Both these examples print: &#8216;The days you chose are: Monday Tuesday Thursday&#8217;.</p>
+<p>By default, missing strings are replaced by &#8216;&#8217; and missing/bad numbers
+by zero. (A&#8217;bad number&#8217; means the converter raised an exception for
+it, usually because of non-numeric characters in the value.) This
+mimics Perl/PHP behavior, and simplifies coding for many applications
+where missing/bad values <em>should</em> be blank/zero. In those relatively
+few cases where you must distinguish between empty-string/zero on the
+one hand and missing/bad on the other, change the appropriate
+&#8216;default*&#8217; and &#8216;bad*&#8217; arguments to something like:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span>* None
+* another constant value
+* $NonNumericInputError/self.NonNumericInputError
+* $ValueError/ValueError
+</pre></div>
+</div>
+<p>(NonNumericInputError is defined in this class and is useful for
+distinguishing between bad input vs a TypeError/ValueError thrown for
+some other rason.)</p>
+<p>Here&#8217;s an example using multiple values to schedule newspaper
+deliveries. &#8216;checkboxes&#8217; comes from a form with checkboxes for all the
+days of the week. The days the user previously chose are preselected.
+The user checks/unchecks boxes as desired and presses Submit. The value
+of &#8216;checkboxes&#8217; is a list of checkboxes that were checked when Submit
+was pressed. Our task now is to turn on the days the user checked, turn
+off the days he unchecked, and leave on or off the days he didn&#8217;t
+change.</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">dic</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">webInput</span><span class="p">([],</span> <span class="p">[</span><span class="s1">&#39;dayCheckboxes&#39;</span><span class="p">])</span>
+<span class="n">wantedDays</span> <span class="o">=</span> <span class="n">dic</span><span class="p">[</span><span class="s1">&#39;dayCheckboxes&#39;</span><span class="p">]</span> <span class="c1"># The days the user checked.</span>
+<span class="k">for</span> <span class="n">day</span><span class="p">,</span> <span class="n">on</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">getAllValues</span><span class="p">():</span>
+ <span class="k">if</span> <span class="ow">not</span> <span class="n">on</span> <span class="ow">and</span> <span class="n">day</span> <span class="ow">in</span> <span class="n">wantedDays</span><span class="p">:</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">TurnOn</span><span class="p">(</span><span class="n">day</span><span class="p">)</span>
+ <span class="c1"># ... Set a flag or insert a database record ...</span>
+ <span class="k">elif</span> <span class="n">on</span> <span class="ow">and</span> <span class="n">day</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">wantedDays</span><span class="p">:</span>
+ <span class="bp">self</span><span class="o">.</span><span class="n">TurnOff</span><span class="p">(</span><span class="n">day</span><span class="p">)</span>
+ <span class="c1"># ... Unset a flag or delete a database record ...</span>
+</pre></div>
+</div>
+<p>&#8216;source&#8217; allows you to look up the variables from a number of different
+sources:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="s1">&#39;f&#39;</span> <span class="n">fields</span> <span class="p">(</span><span class="n">CGI</span> <span class="n">GET</span><span class="o">/</span><span class="n">POST</span> <span class="n">parameters</span><span class="p">)</span>
+<span class="s1">&#39;c&#39;</span> <span class="n">cookies</span>
+<span class="s1">&#39;s&#39;</span> <span class="n">session</span> <span class="n">variables</span>
+<span class="s1">&#39;v&#39;</span> <span class="s1">&#39;values&#39;</span><span class="p">,</span> <span class="n">meaning</span> <span class="n">fields</span> <span class="ow">or</span> <span class="n">cookies</span>
+</pre></div>
+</div>
+<p>In many forms, you&#8217;re dealing only with strings, which is why the
+&#8216;default&#8217; argument is third and the numeric arguments are banished to
+the end. But sometimes you want automatic number conversion, so that
+you can do numeric comparisions in your templates without having to
+write a bunch of conversion/exception handling code. Example:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span>#silent $webInput([&#39;name&#39;, &#39;height:int&#39;])
+$name is $height cm tall.
+#if $height &gt;= 300
+Wow, you&#39;re tall!
+#else
+Pshaw, you&#39;re short.
+#end if
+
+dic = self.webInput([&#39;name&#39;, &#39;height:int&#39;])
+name = dic[name]
+height = dic[height]
+write(&#39;%s is %s cm tall.&#39; % (name, height))
+if height &gt; 300:
+ write(&#39;Wow, you&#39;re tall!&#39;)
+else:
+ write(&#39;Pshaw, you&#39;re short.&#39;)
+</pre></div>
+</div>
+<p>To convert a value to a number, suffix &#8216;:int&#8217; or &#8216;:float&#8217; to the name.
+The method will search first for a &#8216;height:int&#8217; variable and then for a
+&#8216;height&#8217; variable. (It will be called &#8216;height&#8217; in the final
+dictionary.) If a numeric conversion fails, use or raise &#8216;badInt&#8217; or
+&#8216;badFloat&#8217;. Missing values work the same way as for strings, except the
+default is &#8216;defaultInt&#8217; or &#8216;defaultFloat&#8217; instead of &#8216;default&#8217;.</p>
+<p>If a name represents an uploaded file, the entire file will be read into
+memory. For more sophistocated file-upload handling, leave that name
+out of the list and do your own handling, or wait for
+Cheetah.Utils.UploadFileMixin.</p>
+<p>This only in a subclass that also inherits from Webware&#8217;s Servlet or
+HTTPServlet. Otherwise you&#8217;ll get an AttributeError on &#8216;self.request&#8217;.</p>
+<p>EXCEPTIONS: ValueError if &#8216;source&#8217; is not one of the stated characters.
+TypeError if a conversion suffix is not &#8216;:int&#8217; or &#8216;:float&#8217;.</p>
+<p>FUTURE EXPANSION: a future version of this method may allow source
+cascading; e.g., &#8216;vs&#8217; would look first in &#8216;values&#8217; and then in session
+variables.</p>
+<p>Meta-Data:</p>
+<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">Author</span><span class="p">:</span> <span class="n">Mike</span> <span class="n">Orr</span> <span class="o">&lt;</span><span class="n">iron</span><span class="nd">@mso</span><span class="o">.</span><span class="n">oz</span><span class="o">.</span><span class="n">net</span><span class="o">&gt;</span>
+<span class="n">License</span><span class="p">:</span> <span class="n">This</span> <span class="n">software</span> <span class="ow">is</span> <span class="n">released</span> <span class="k">for</span> <span class="n">unlimited</span> <span class="n">distribution</span> <span class="n">under</span> <span class="n">the</span>
+ <span class="n">terms</span> <span class="n">of</span> <span class="n">the</span> <span class="n">MIT</span> <span class="n">license</span><span class="o">.</span> <span class="n">See</span> <span class="n">the</span> <span class="n">LICENSE</span> <span class="n">file</span><span class="o">.</span>
+<span class="n">Version</span><span class="p">:</span> <span class="mf">1.186</span>
+<span class="n">Start</span> <span class="n">Date</span><span class="p">:</span> <span class="mi">2002</span><span class="o">/</span><span class="mi">03</span><span class="o">/</span><span class="mi">17</span>
+<span class="n">Last</span> <span class="n">Revision</span> <span class="n">Date</span><span class="p">:</span> <span class="mi">2008</span><span class="o">/</span><span class="mi">03</span><span class="o">/</span><span class="mi">10</span> <span class="mi">04</span><span class="p">:</span><span class="mi">48</span><span class="p">:</span><span class="mi">11</span>
+</pre></div>
+</div>
+</dd></dl>
+
+</dd></dl>
+
+<dl class="class">
+<dt id="Cheetah.Template.TemplatePreprocessor">
+<em class="property">class </em><code class="descclassname">Cheetah.Template.</code><code class="descname">TemplatePreprocessor</code><span class="sig-paren">(</span><em>settings</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.TemplatePreprocessor" title="Permalink to this definition">¶</a></dt>
+<dd><p>Bases: <code class="xref py py-class docutils literal"><span class="pre">object</span></code></p>
+<p>This is used with the preprocessors argument to Template.compile().</p>
+<p>See the docstring for Template.compile</p>
+<p>** Preprocessors are an advanced topic **</p>
+<dl class="method">
+<dt id="Cheetah.Template.TemplatePreprocessor.preprocess">
+<code class="descname">preprocess</code><span class="sig-paren">(</span><em>source</em>, <em>file</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.TemplatePreprocessor.preprocess" title="Permalink to this definition">¶</a></dt>
+<dd><p>Create an intermediate template and return the source code
+it outputs</p>
+</dd></dl>
+
+</dd></dl>
+
+<dl class="function">
+<dt id="Cheetah.Template.checkFileMtime">
+<code class="descclassname">Cheetah.Template.</code><code class="descname">checkFileMtime</code><span class="sig-paren">(</span><em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.checkFileMtime" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="function">
+<dt id="Cheetah.Template.createMethod">
+<code class="descclassname">Cheetah.Template.</code><code class="descname">createMethod</code><span class="sig-paren">(</span><em>func</em>, <em>cls</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.createMethod" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="function">
+<dt id="Cheetah.Template.genParserErrorFromPythonException">
+<code class="descclassname">Cheetah.Template.</code><code class="descname">genParserErrorFromPythonException</code><span class="sig-paren">(</span><em>source</em>, <em>file</em>, <em>generatedPyCode</em>, <em>exception</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.genParserErrorFromPythonException" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="function">
+<dt id="Cheetah.Template.hashDict">
+<code class="descclassname">Cheetah.Template.</code><code class="descname">hashDict</code><span class="sig-paren">(</span><em>d</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.hashDict" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="function">
+<dt id="Cheetah.Template.hashList">
+<code class="descclassname">Cheetah.Template.</code><code class="descname">hashList</code><span class="sig-paren">(</span><em>l</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.hashList" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+<dl class="function">
+<dt id="Cheetah.Template.updateLinecache">
+<code class="descclassname">Cheetah.Template.</code><code class="descname">updateLinecache</code><span class="sig-paren">(</span><em>filename</em>, <em>src</em><span class="sig-paren">)</span><a class="headerlink" href="#Cheetah.Template.updateLinecache" title="Permalink to this definition">¶</a></dt>
+<dd></dd></dl>
+
+</div>
+
+
+ </div>
+ </div>
+ </div>
+ <div class="clearer"></div>
+ </div>
+ <div class="related" role="navigation" aria-label="related navigation">
+ <h3>Navigation</h3>
+ <ul>
+ <li class="right" style="margin-right: 10px">
+ <a href="../genindex.html" title="General Index"
+ >index</a></li>
+ <li class="right" >
+ <a href="../py-modindex.html" title="Python Module Index"
+ >modules</a> |</li>
+ <li class="nav-item nav-item-0"><a href="../index.html">Cheetah3 - The Python-Powered Template Engine</a> &#187;</li>
+ </ul>
+ </div>
+ <div class="footer" role="contentinfo">
+ &#169; Copyright 2017, Oleg Broytman; 2009-2012, R. Tyler Croy; 2001-2008, The Cheetah Development Team..
+ Last updated on May 07, 2017.
+ Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.5.5.
+ </div>
+ </body>
+</html> \ No newline at end of file