class documentation

class Variable:

View In Hierarchy

A template variable, resolvable against a given context. The variable may be a hard-coded string (if it begins and ends with single or double quote marks):

>>> c = {'article': {'section':'News'}}
>>> Variable('article.section').resolve(c)
'News'
>>> Variable('article').resolve(c)
{'section': 'News'}
>>> class AClass: pass
>>> c = AClass()
>>> c.article = AClass()
>>> c.article.section = 'News'

(The example assumes VARIABLE_ATTRIBUTE_SEPARATOR is '.')

Method __init__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method ​_resolve​_lookup Perform resolution of a real variable (i.e. not a literal) against the given context.
Method resolve Resolve this variable against a given context.
Instance Variable literal Undocumented
Instance Variable lookups Undocumented
Instance Variable message​_context Undocumented
Instance Variable translate Undocumented
Instance Variable var Undocumented
def __init__(self, var):

Undocumented

def __repr__(self):

Undocumented

def __str__(self):

Undocumented

def _resolve_lookup(self, context):

Perform resolution of a real variable (i.e. not a literal) against the given context.

As indicated by the method's name, this method is an implementation detail and shouldn't be called by external code. Use Variable.resolve() instead.

def resolve(self, context):
Resolve this variable against a given context.
literal =

Undocumented

lookups =

Undocumented

message_context =

Undocumented

translate: bool =

Undocumented

var =

Undocumented