class Context: (source)
Provides runtime namespace, output buffer, and various callstacks for templates. See :ref:`runtime_toplevel` for detail on the usage of :class:`.Context`.
Method | __getitem__ |
Undocumented |
Method | __init__ |
Undocumented |
Method | get |
Return a value from this :class:`.Context`. |
Method | keys |
Return a list of all names established in this :class:`.Context`. |
Method | pop |
Pop a ``caller`` callable onto the callstack for this :class:`.Context`. |
Method | push |
Push a ``caller`` callable onto the callstack for this :class:`.Context`. |
Method | write |
Write a string to this :class:`.Context` object's underlying output buffer. |
Method | writer |
Return the current writer function. |
Instance Variable | caller |
Undocumented |
Instance Variable | namespaces |
Undocumented |
Property | kwargs |
Return the dictionary of top level keyword arguments associated with this :class:`.Context`. |
Property | lookup |
Return the :class:`.TemplateLookup` associated with this :class:`.Context`. |
Method | _clean |
create a new copy of this :class:`.Context`. with tokens related to inheritance state removed. |
Method | _copy |
Undocumented |
Method | _locals |
Create a new :class:`.Context` with a copy of this :class:`.Context`'s current state, updated with the given dictionary. |
Method | _pop |
pop the most recent capturing buffer from this Context. |
Method | _pop |
pop the most recent capturing buffer from this Context and return the current writer after the pop. |
Method | _push |
push a capturing buffer onto this Context. |
Method | _push |
push a capturing buffer onto this Context and return the new writer function. |
Method | _set |
Undocumented |
Instance Variable | _buffer |
Undocumented |
Instance Variable | _data |
Undocumented |
Instance Variable | _kwargs |
Undocumented |
Instance Variable | _outputting |
Undocumented |
Instance Variable | _with |
Undocumented |
Return the dictionary of top level keyword arguments associated with this :class:`.Context`. This dictionary only includes the top-level arguments passed to :meth:`.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 :class:`.Template` accepts arguments via its ``<%page>`` tag, which are normally expected to be passed via :meth:`.Template.render`, except the template is being called in an inheritance context, using the ``body()`` method. :attr:`.Context.kwargs` can then be used to propagate these arguments to the inheriting template:: ${next.body(**context.kwargs)}
Create a new :class:`.Context` with a copy of this :class:`.Context`'s current state, updated with the given dictionary. The :attr:`.Context.kwargs` collection remains unaffected.