Container for template input data.
A context provides a stack of scopes (represented by dictionaries).
Template directives such as loops can push a new scope on the stack with
data that should only be available inside the loop. When the loop
terminates, that scope can get popped off the stack again.
|
__init__(self,
**data)
Initialize the template context with the given keyword arguments as
data. |
|
|
|
|
|
__contains__(self,
key)
Return whether a variable exists in any of the scopes. |
|
|
|
has_key(self,
key)
Return whether a variable exists in any of the scopes. |
|
|
|
__delitem__(self,
key)
Remove a variable from all scopes. |
|
|
|
__getitem__(self,
key)
Get a variables's value, starting at the current scope and going
upward. |
|
|
|
__len__(self)
Return the number of distinctly named variables in the context. |
|
|
|
__setitem__(self,
key,
value)
Set a variable in the current scope. |
|
|
|
get(self,
key,
default=None)
Get a variable's value, starting at the current scope and going
upward. |
|
|
|
keys(self)
Return the name of all variables in the context. |
|
|
|
items(self)
Return a list of (name, value) tuples for all variables in the
context. |
|
|
|
update(self,
mapping)
Update the context from the mapping provided. |
|
|
|
push(self,
data)
Push a new scope on the stack. |
|
|
|
pop(self)
Pop the top-most scope from the stack. |
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|