class Context(object):
Provides runtime namespace, output buffer, and various callstacks for templates.
See :ref:`runtime_toplevel` for detail on the usage of
.Context
.
Method | get |
Return a value from this .Context . |
Method | keys |
Return a list of all names established in this .Context . |
Method | pop_caller |
Pop a caller callable onto the callstack for this .Context . |
Method | push_caller |
Push a caller callable onto the callstack for this .Context . |
Method | write |
Write a string to this .Context object's underlying output buffer. |
Method | writer |
Return the current writer function. |
Method | __getitem__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | _clean_inheritance_tokens |
create a new copy of this .Context . with tokens related to inheritance state removed. |
Method | _copy |
Undocumented |
Method | _locals |
Create a new .Context with a copy of this .Context 's current state, updated with the given dictionary. |
Method | _pop_buffer |
pop the most recent capturing buffer from this Context. |
Method | _pop_buffer_and_writer |
pop the most recent capturing buffer from this Context and return the current writer after the pop. |
Method | _push_buffer |
push a capturing buffer onto this Context. |
Method | _push_writer |
push a capturing buffer onto this Context and return the new writer function. |
Method | _set_with_template |
Undocumented |
Instance Variable | _buffer_stack |
Undocumented |
Instance Variable | _data |
Undocumented |
Instance Variable | _kwargs |
Undocumented |
Instance Variable | _outputting_as_unicode |
Undocumented |
Instance Variable | _with_template |
Undocumented |
Instance Variable | caller_stack |
Undocumented |
Instance Variable | namespaces |
Undocumented |
Property | kwargs |
Return the dictionary of top level keyword arguments associated with this .Context . |
Property | lookup |
Return the .TemplateLookup associated with this .Context . |
.Context
. with
tokens related to inheritance state removed.Create a new .Context
with a copy of this
.Context
's current state,
updated with the given dictionary.
The .Context.kwargs
collection remains
unaffected.
Return the dictionary of top level keyword arguments associated
with this .Context
.
This dictionary only includes the top-level arguments passed to
.Template.render
. It does not include names produced within
the template execution such as local variable names or special names
such as self, next, etc.
The purpose of this dictionary is primarily for the case that
a .Template
accepts arguments via its <%page> tag,
which are normally expected to be passed via .Template.render
,
except the template is being called in an inheritance context,
using the body() method. .Context.kwargs
can then be
used to propagate these arguments to the inheriting template:
${next.body(**context.kwargs)}