class documentation

class Context(object):

View In Hierarchy

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.
def get(self, key, default=None):
Return a value from this .Context.
def keys(self):
Return a list of all names established in this .Context.
def pop_caller(self):
Pop a caller callable onto the callstack for this .Context.
def push_caller(self, caller):
Push a caller callable onto the callstack for this .Context.
def write(self, string):
Write a string to this .Context object's underlying output buffer.
def writer(self):
Return the current writer function.
def __getitem__(self, key):

Undocumented

def __init__(self, buffer, **data):

Undocumented

def _clean_inheritance_tokens(self):
create a new copy of this .Context. with tokens related to inheritance state removed.
def _copy(self):

Undocumented

def _locals(self, d):

Create a new .Context with a copy of this .Context's current state, updated with the given dictionary.

The .Context.kwargs collection remains unaffected.

def _pop_buffer(self):
pop the most recent capturing buffer from this Context.
def _pop_buffer_and_writer(self):
pop the most recent capturing buffer from this Context and return the current writer after the pop.
def _push_buffer(self):
push a capturing buffer onto this Context.
def _push_writer(self):
push a capturing buffer onto this Context and return the new writer function.
def _set_with_template(self, t):

Undocumented

_buffer_stack =

Undocumented

_data =

Undocumented

_kwargs =

Undocumented

_outputting_as_unicode =

Undocumented

_with_template =

Undocumented

caller_stack =

Undocumented

namespaces: dict =

Undocumented

@property
kwargs =

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)}
@property
lookup =
Return the .TemplateLookup associated with this .Context.