Sophie

Sophie

distrib > Fedora > 14 > x86_64 > media > updates > by-pkgid > 174107171d05f96998bd4cf15e0088c4 > files > 111

python-mako-0.3.6-1.fc14.noarch.rpm

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        
        <title>
    The Mako Runtime Environment
 &mdash; Mako 0.3.6 Documentation</title>
        
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/docs.css" type="text/css" />

    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '#',
          VERSION:     '0.3.6',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </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>
    <script type="text/javascript" src="_static/init.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="Mako 0.3.6 Documentation" href="index.html" />
        <link rel="next" title="Namespaces" href="namespaces.html" />
        <link rel="prev" title="Defs" href="defs.html" />
    

    </head>
    <body>
        




        <h1>Mako 0.3.6 Documentation</h1>

        <div id="search">
        Search:
        <form class="search" action="search.html" method="get">
          <input type="text" name="q" size="18" /> <input type="submit" value="Search" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
        </div>

        <div class="versionheader">
            Version: <span class="versionnum">0.3.6</span> Last Updated: 11/13/2010 16:04:30
        </div>
        <div class="clearboth"></div>

        <div class="topnav">
            <div id="pagecontrol">
                <a href="genindex.html">Index</a>
            
                <div class="sourcelink">(<a href="_sources/runtime.txt">view source)</div>
            </div>
            
            <div class="navbanner">
                <a class="totoc" href="index.html">Table of Contents</a>
                » 
    The Mako Runtime Environment
 
                
                
<div class="prevnext">
        Previous:
        <a href="defs.html" title="previous chapter">Defs</a>
        Next:
        <a href="namespaces.html" title="next chapter">Namespaces</a>
</div>

                <h2>
                    
    The Mako Runtime Environment
 
                </h2>
            </div>
                <ul>
<li><a class="reference internal" href="#">The Mako Runtime Environment</a><ul>
<li><a class="reference internal" href="#context">Context</a><ul>
<li><a class="reference internal" href="#the-buffer">The Buffer</a></li>
<li><a class="reference internal" href="#context-variables">Context Variables</a></li>
<li><a class="reference internal" href="#context-methods-and-accessors">Context Methods and Accessors</a></li>
</ul>
</li>
<li><a class="reference internal" href="#all-the-built-in-names">All the built-in names</a></li>
<li><a class="reference internal" href="#api-reference">API Reference</a></li>
</ul>
</li>
</ul>

            <div class="clearboth"></div>
        </div>
        
        <div class="document">
            <div class="body">
                
<div class="section" id="the-mako-runtime-environment">
<span id="runtime-toplevel"></span><h1>The Mako Runtime Environment<a class="headerlink" href="#the-mako-runtime-environment" title="Permalink to this headline">¶</a></h1>
<p>This section describes a little bit about the objects and
built-in functions that are available in templates.</p>
<div class="section" id="context">
<h2>Context<a class="headerlink" href="#context" title="Permalink to this headline">¶</a></h2>
<p>The <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> is the central object that is created when
a template is first executed, and is responsible for handling
all communication with the outside world. This includes two
major components, one of which is the output buffer, which is a
file-like object such as Python&#8217;s <tt class="docutils literal"><span class="pre">StringIO</span></tt> or similar, and
the other a dictionary of variables that can be freely
referenced within a template; this dictionary is a combination
of the arguments sent to the <a class="reference internal" href="usage.html#mako.template.Template.render" title="mako.template.Template.render"><tt class="xref py py-meth docutils literal"><span class="pre">render()</span></tt></a> function and
some built-in variables provided by Mako&#8217;s runtime environment.</p>
<div class="section" id="the-buffer">
<h3>The Buffer<a class="headerlink" href="#the-buffer" title="Permalink to this headline">¶</a></h3>
<p>The buffer is stored within the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>, and writing
to it is achieved by calling <a class="reference internal" href="#mako.runtime.Context.write" title="mako.runtime.Context.write"><tt class="xref py py-meth docutils literal"><span class="pre">Context.write()</span></tt></a>. You usually
don&#8217;t need to care about this as all text within a template, as
well as all expressions provided by <tt class="docutils literal"><span class="pre">${}</span></tt>, automatically send
everything to this method. The cases you might want to be aware
of its existence are if you are dealing with various
filtering/buffering scenarios, which are described in
<a class="reference internal" href="filtering.html"><em>Filtering and Buffering</em></a>, or if you want to programmatically
send content to the output stream, such as within a <tt class="docutils literal"><span class="pre">&lt;%</span> <span class="pre">%&gt;</span></tt>
block.</p>
<div class="highlight-mako"><div class="highlight"><pre><span class="cp">&lt;%</span>
    <span class="n">context</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">&quot;some programmatic text&quot;</span><span class="p">)</span>
<span class="cp">%&gt;</span><span class="x"></span>
</pre></div>
</div>
<p>The actual buffer may or may not be the original buffer sent to
the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> object, as various filtering/caching
scenarios may &#8220;push&#8221; a new buffer onto the context&#8217;s underlying
buffer stack. For this reason, just stick with
<a class="reference internal" href="#mako.runtime.Context.write" title="mako.runtime.Context.write"><tt class="xref py py-meth docutils literal"><span class="pre">Context.write()</span></tt></a> and content will always go to the topmost
buffer.</p>
</div>
<div class="section" id="context-variables">
<h3>Context Variables<a class="headerlink" href="#context-variables" title="Permalink to this headline">¶</a></h3>
<p>When your template is compiled into a Python module, the body
content is enclosed within a Python function called
<tt class="docutils literal"><span class="pre">render_body</span></tt>. Other top-level defs defined in the template are
defined within their own function bodies which are named after
the def&#8217;s name with the prefix <tt class="docutils literal"><span class="pre">render_</span></tt> (i.e. <tt class="docutils literal"><span class="pre">render_mydef</span></tt>).
One of the first things that happens within these functions is
that all variable names that are referenced within the function
which are not defined in some other way (i.e. such as via
assignment, module level imports, etc.) are pulled from the
<a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> object&#8217;s dictionary of variables. This is how you&#8217;re
able to freely reference variable names in a template which
automatically correspond to what was passed into the current
<a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
<ul class="simple">
<li><strong>What happens if I reference a variable name that is not in
the current context?</strong> - the value you get back is a special
value called <tt class="docutils literal"><span class="pre">UNDEFINED</span></tt>, or if the <tt class="docutils literal"><span class="pre">strict_undefined=True</span></tt> flag
is used a <tt class="docutils literal"><span class="pre">NameError</span></tt> is raised. <tt class="docutils literal"><span class="pre">UNDEFINED</span></tt> is just a simple global
variable with the class <tt class="docutils literal"><span class="pre">mako.runtime.Undefined</span></tt>. The
<tt class="docutils literal"><span class="pre">UNDEFINED</span></tt> object throws an error when you call <tt class="docutils literal"><span class="pre">str()</span></tt> on
it, which is what happens if you try to use it in an
expression.</li>
<li><strong>UNDEFINED makes it hard for me to find what name is missing</strong> - An alternative
introduced in version 0.3.6 is to specify the option
<tt class="docutils literal"><span class="pre">strict_undefined=True</span></tt>
to the <a class="reference internal" href="usage.html#mako.template.Template" title="mako.template.Template"><tt class="xref py py-class docutils literal"><span class="pre">Template</span></tt></a> or <a class="reference internal" href="usage.html#mako.lookup.TemplateLookup" title="mako.lookup.TemplateLookup"><tt class="xref py py-class docutils literal"><span class="pre">TemplateLookup</span></tt></a>.   This will cause
any non-present variables to raise an immediate <tt class="docutils literal"><span class="pre">NameError</span></tt>
which includes the name of the variable in its message
when <a class="reference internal" href="usage.html#mako.template.Template.render" title="mako.template.Template.render"><tt class="xref py py-meth docutils literal"><span class="pre">render()</span></tt></a> is called - <tt class="docutils literal"><span class="pre">UNDEFINED</span></tt> is not used.</li>
<li><strong>Why not just return None?</strong> Using <tt class="docutils literal"><span class="pre">UNDEFINED</span></tt>, or
raising a <tt class="docutils literal"><span class="pre">NameError</span></tt> is more
explicit and allows differentiation between a value of <tt class="xref docutils literal"><span class="pre">None</span></tt>
that was explicitly passed to the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> and a value that
wasn&#8217;t present at all.</li>
<li><strong>Why raise an exception when you call str() on it ? Why not
just return a blank string?</strong> - Mako tries to stick to the
Python philosophy of &#8220;explicit is better than implicit&#8221;. In
this case, its decided that the template author should be made
to specifically handle a missing value rather than
experiencing what may be a silent failure. Since <tt class="docutils literal"><span class="pre">UNDEFINED</span></tt>
is a singleton object just like Python&#8217;s <tt class="xref docutils literal"><span class="pre">True</span></tt> or <tt class="xref docutils literal"><span class="pre">False</span></tt>,
you can use the <tt class="docutils literal"><span class="pre">is</span></tt> operator to check for it:</li>
</ul>
<blockquote>
<div class="highlight-mako"><div class="highlight"><pre><span class="cp">%</span> <span class="k">if</span> <span class="n">someval</span> <span class="ow">is</span> <span class="n">UNDEFINED</span><span class="p">:</span><span class="x"></span>
<span class="x">    someval is: no value</span>
<span class="cp">%</span> <span class="k">else</span><span class="p">:</span><span class="x"></span>
<span class="x">    someval is: </span><span class="cp">${</span><span class="n">someval</span><span class="cp">}</span>
<span class="cp">%</span><span class="k"> endif</span><span class="x"></span>
</pre></div>
</div>
</blockquote>
<p>Another facet of the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> is that its dictionary of
variables is <strong>immutable</strong>. Whatever is set when
<a class="reference internal" href="usage.html#mako.template.Template.render" title="mako.template.Template.render"><tt class="xref py py-meth docutils literal"><span class="pre">render()</span></tt></a> is called is what stays. Of course, since
its Python, you can hack around this and change values in the
context&#8217;s internal dictionary, but this will probably will not
work as well as you&#8217;d think. The reason for this is that Mako in
many cases creates copies of the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> object, which
get sent to various elements of the template and inheriting
templates used in an execution. So changing the value in your
local <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> will not necessarily make that value
available in other parts of the template&#8217;s execution. Examples
of where Mako creates copies of the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> include
within top-level def calls from the main body of the template
(the context is used to propagate locally assigned variables
into the scope of defs; since in the template&#8217;s body they appear
as inlined functions, Mako tries to make them act that way), and
within an inheritance chain (each template in an inheritance
chain has a different notion of <tt class="docutils literal"><span class="pre">parent</span></tt> and <tt class="docutils literal"><span class="pre">next</span></tt>, which
are all stored in unique <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> instances).</p>
<ul>
<li><p class="first"><strong>So what if I want to set values that are global to everyone
within a template request?</strong> - All you have to do is provide a
dictionary to your <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> when the template first
runs, and everyone can just get/set variables from that. Lets
say its called <tt class="docutils literal"><span class="pre">attributes</span></tt>.</p>
<p>Running the template looks like:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">output</span> <span class="o">=</span> <span class="n">template</span><span class="o">.</span><span class="n">render</span><span class="p">(</span><span class="n">attributes</span><span class="o">=</span><span class="p">{})</span>
</pre></div>
</div>
<p>Within a template, just reference the dictionary:</p>
<div class="highlight-mako"><div class="highlight"><pre><span class="cp">&lt;%</span>
    <span class="n">attributes</span><span class="p">[</span><span class="s">&#39;foo&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s">&#39;bar&#39;</span>
<span class="cp">%&gt;</span><span class="x"></span>
<span class="x">&#39;foo&#39; attribute is: </span><span class="cp">${</span><span class="n">attributes</span><span class="p">[</span><span class="s">&#39;foo&#39;</span><span class="p">]</span><span class="cp">}</span><span class="x"></span>
</pre></div>
</div>
</li>
<li><p class="first"><strong>Why can&#8217;t &#8220;attributes&#8221; be a built-in feature of the
Context?</strong> - This is an area where Mako is trying to make as
few decisions about your application as it possibly can.
Perhaps you don&#8217;t want your templates to use this technique of
assigning and sharing data, or perhaps you have a different
notion of the names and kinds of data structures that should
be passed around. Once again Mako would rather ask the user to
be explicit.</p>
</li>
</ul>
</div>
<div class="section" id="context-methods-and-accessors">
<h3>Context Methods and Accessors<a class="headerlink" href="#context-methods-and-accessors" title="Permalink to this headline">¶</a></h3>
<p>Significant members off of <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> include:</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">context[key]</span></tt> / <tt class="docutils literal"><span class="pre">context.get(key,</span> <span class="pre">default=None)</span></tt> -
dictionary-like accessors for the context. Normally, any
variable you use in your template is automatically pulled from
the context if it isnt defined somewhere already. Use the
dictionary accessor and/or <tt class="docutils literal"><span class="pre">get</span></tt> method when you want a
variable that <em>is</em> already defined somewhere else, such as in
the local arguments sent to a %def call. If a key is not
present, like a dictionary it raises <tt class="docutils literal"><span class="pre">KeyError</span></tt>.</li>
<li><tt class="docutils literal"><span class="pre">keys()</span></tt> - all the names defined within this context.</li>
<li><tt class="docutils literal"><span class="pre">kwargs</span></tt> - this returns a <strong>copy</strong> of the context&#8217;s
dictionary of variables. This is useful when you want to
propagate the variables in the current context to a function
as keyword arguments, i.e.:</li>
</ul>
<div class="highlight-mako"><div class="highlight"><pre><span class="cp">${</span><span class="nb">next</span><span class="o">.</span><span class="n">body</span><span class="p">(</span><span class="o">**</span><span class="n">context</span><span class="o">.</span><span class="n">kwargs</span><span class="p">)</span><span class="cp">}</span><span class="x"></span>
</pre></div>
</div>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">write(text)</span></tt> - write some text to the current output
stream.</li>
<li><tt class="docutils literal"><span class="pre">lookup</span></tt> - returns the <a class="reference internal" href="usage.html#mako.lookup.TemplateLookup" title="mako.lookup.TemplateLookup"><tt class="xref py py-class docutils literal"><span class="pre">TemplateLookup</span></tt></a> instance that is
used for all file-lookups within the current execution (even
though individual <a class="reference internal" href="usage.html#mako.template.Template" title="mako.template.Template"><tt class="xref py py-class docutils literal"><span class="pre">Template</span></tt></a> instances can conceivably have
different instances of a <a class="reference internal" href="usage.html#mako.lookup.TemplateLookup" title="mako.lookup.TemplateLookup"><tt class="xref py py-class docutils literal"><span class="pre">TemplateLookup</span></tt></a>, only the
<a class="reference internal" href="usage.html#mako.lookup.TemplateLookup" title="mako.lookup.TemplateLookup"><tt class="xref py py-class docutils literal"><span class="pre">TemplateLookup</span></tt></a> of the originally-called <a class="reference internal" href="usage.html#mako.template.Template" title="mako.template.Template"><tt class="xref py py-class docutils literal"><span class="pre">Template</span></tt></a> gets
used in a particular execution).</li>
</ul>
</div>
</div>
<div class="section" id="all-the-built-in-names">
<h2>All the built-in names<a class="headerlink" href="#all-the-built-in-names" title="Permalink to this headline">¶</a></h2>
<p>A one-stop shop for all the names Mako defines. Most of these
names are instances of <a class="reference internal" href="namespaces.html#mako.runtime.Namespace" title="mako.runtime.Namespace"><tt class="xref py py-class docutils literal"><span class="pre">Namespace</span></tt></a>, which are described
in the next section, <a class="reference internal" href="namespaces.html"><em>Namespaces</em></a>. Also, most of
these names other than <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> and <tt class="docutils literal"><span class="pre">UNDEFINED</span></tt> are
also present <em>within</em> the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> itself.</p>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">local</span></tt> - the namespace of the current template, described
in <a class="reference internal" href="namespaces.html#namespaces-builtin"><em>Built-in Namespaces</em></a>.</li>
<li><tt class="docutils literal"><span class="pre">self</span></tt> - the namespace of the topmost template in an
inheritance chain (if any, otherwise the same as <tt class="docutils literal"><span class="pre">local</span></tt>),
mostly described in <a class="reference internal" href="inheritance.html"><em>Inheritance</em></a>.</li>
<li><tt class="docutils literal"><span class="pre">parent</span></tt> - the namespace of the parent template in an
inheritance chain (otherwise undefined); see
<a class="reference internal" href="inheritance.html"><em>Inheritance</em></a>.</li>
<li><tt class="docutils literal"><span class="pre">next</span></tt> - the namespace of the next template in an
inheritance chain (otherwise undefined); see
<a class="reference internal" href="inheritance.html"><em>Inheritance</em></a>.</li>
<li><tt class="docutils literal"><span class="pre">caller</span></tt> - a &#8220;mini&#8221; namespace created when using the
<tt class="docutils literal"><span class="pre">&lt;%call&gt;</span></tt> tag to define a &#8220;def call with content&#8221;; described
in <a class="reference internal" href="defs.html#defs-with-content"><em>Calling a def with embedded content and/or other defs</em></a>.</li>
<li><tt class="docutils literal"><span class="pre">capture</span></tt> - a function that calls a given def and captures
its resulting content into a string, which is returned. Usage
is described in <a class="reference internal" href="filtering.html"><em>Filtering and Buffering</em></a>.</li>
<li><tt class="docutils literal"><span class="pre">UNDEFINED</span></tt> - a global singleton that is applied to all
otherwise uninitialized template variables that were not
located within the <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> when rendering began,
unless the <a class="reference internal" href="usage.html#mako.template.Template" title="mako.template.Template"><tt class="xref py py-class docutils literal"><span class="pre">Template</span></tt></a> flag <tt class="docutils literal"><span class="pre">strict_undefined</span></tt>
is set to <tt class="xref docutils literal"><span class="pre">True</span></tt>. <tt class="docutils literal"><span class="pre">UNDEFINED</span></tt> is
an instance of <a class="reference internal" href="#mako.runtime.Undefined" title="mako.runtime.Undefined"><tt class="xref py py-class docutils literal"><span class="pre">Undefined</span></tt></a>, and raises an
exception when its <tt class="docutils literal"><span class="pre">__str__()</span></tt> method is called.</li>
<li><tt class="docutils literal"><span class="pre">pageargs</span></tt> - this is a dictionary which is present in a
template which does not define any **kwargs section in its
<tt class="docutils literal"><span class="pre">&lt;%page&gt;</span></tt> tag. All keyword arguments sent to the <tt class="docutils literal"><span class="pre">body()</span></tt>
function of a template (when used via namespaces) go here by
default unless otherwise defined as a page argument. If this
makes no sense, it shouldn&#8217;t; read the section
<a class="reference internal" href="namespaces.html#namespaces-body"><em>The &#8220;body()&#8221; method</em></a>.</li>
</ul>
</div>
<div class="section" id="api-reference">
<h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="mako.runtime.Context">
<em class="property">class </em><tt class="descclassname">mako.runtime.</tt><tt class="descname">Context</tt><big>(</big><em>buffer</em>, <em>**data</em><big>)</big><a class="headerlink" href="#mako.runtime.Context" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Provides runtime namespace, output buffer, and various
callstacks for templates.</p>
<blockquote>
See <a class="reference internal" href="#"><em>The Mako Runtime Environment</em></a> for detail on the usage of</blockquote>
<p><a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
<dl class="method">
<dt id="mako.runtime.Context.get">
<tt class="descname">get</tt><big>(</big><em>key</em>, <em>default=None</em><big>)</big><a class="headerlink" href="#mako.runtime.Context.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a value from this <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="mako.runtime.Context.keys">
<tt class="descname">keys</tt><big>(</big><big>)</big><a class="headerlink" href="#mako.runtime.Context.keys" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of all names established in this <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
</dd></dl>

<dl class="attribute">
<dt id="mako.runtime.Context.kwargs">
<tt class="descname">kwargs</tt><a class="headerlink" href="#mako.runtime.Context.kwargs" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the dictionary of keyword argments associated with this
<a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="mako.runtime.Context.locals_">
<tt class="descname">locals_</tt><big>(</big><em>d</em><big>)</big><a class="headerlink" href="#mako.runtime.Context.locals_" title="Permalink to this definition">¶</a></dt>
<dd><p>create a new <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> with a copy of this 
<tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt>&#8216;s current state, updated with the given dictionary.</p>
</dd></dl>

<dl class="attribute">
<dt id="mako.runtime.Context.lookup">
<tt class="descname">lookup</tt><a class="headerlink" href="#mako.runtime.Context.lookup" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the <a class="reference internal" href="usage.html#mako.lookup.TemplateLookup" title="mako.lookup.TemplateLookup"><tt class="xref py py-class docutils literal"><span class="pre">TemplateLookup</span></tt></a> associated 
with this <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="mako.runtime.Context.pop_caller">
<tt class="descname">pop_caller</tt><big>(</big><big>)</big><a class="headerlink" href="#mako.runtime.Context.pop_caller" title="Permalink to this definition">¶</a></dt>
<dd><p>Pops a &#8216;caller&#8217; callable onto the callstack for this
<a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="mako.runtime.Context.push_caller">
<tt class="descname">push_caller</tt><big>(</big><em>caller</em><big>)</big><a class="headerlink" href="#mako.runtime.Context.push_caller" title="Permalink to this definition">¶</a></dt>
<dd><p>Pushes a &#8216;caller&#8217; callable onto the callstack for
this <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a>.</p>
</dd></dl>

<dl class="method">
<dt id="mako.runtime.Context.write">
<tt class="descname">write</tt><big>(</big><em>string</em><big>)</big><a class="headerlink" href="#mako.runtime.Context.write" title="Permalink to this definition">¶</a></dt>
<dd><p>Write a string to this <a class="reference internal" href="#mako.runtime.Context" title="mako.runtime.Context"><tt class="xref py py-class docutils literal"><span class="pre">Context</span></tt></a> object&#8217;s
underlying output buffer.</p>
</dd></dl>

<dl class="method">
<dt id="mako.runtime.Context.writer">
<tt class="descname">writer</tt><big>(</big><big>)</big><a class="headerlink" href="#mako.runtime.Context.writer" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the current writer function</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="mako.runtime.Undefined">
<em class="property">class </em><tt class="descclassname">mako.runtime.</tt><tt class="descname">Undefined</tt><a class="headerlink" href="#mako.runtime.Undefined" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>Represents an undefined value in a template.</p>
<p>All template modules have a constant value 
<tt class="docutils literal"><span class="pre">UNDEFINED</span></tt> present which is an instance of this
object.</p>
</dd></dl>

</div>
</div>

            </div>
        </div>

        
        
            <div class="bottomnav">
                
<div class="prevnext">
        Previous:
        <a href="defs.html" title="previous chapter">Defs</a>
        Next:
        <a href="namespaces.html" title="next chapter">Namespaces</a>
</div>

                <div class="doc_copyright">
                    &copy; Copyright the Mako authors and contributors.
                    Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
                </div>
            </div>
        






    </body>
</html>