Package genshi :: Package template :: Module eval :: Class LenientLookup

Class LenientLookup

object --+    
         |    
LookupBase --+
             |
            LenientLookup

Default variable lookup mechanism for expressions.

When an undefined variable is referenced using this lookup style, the reference evaluates to an instance of the Undefined class:

>>> expr = Expression('nothing', lookup='lenient')
>>> undef = expr.evaluate({})
>>> undef
<Undefined 'nothing'>

The same will happen when a non-existing attribute or item is accessed on an existing object:

>>> expr = Expression('something.nil', lookup='lenient')
>>> expr.evaluate({'something': dict()})
<Undefined 'nil'>

See the documentation of the Undefined class for details on the behavior of such objects.


See Also: StrictLookup

Instance Methods

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods
 
undefined(cls, key, owner=UNDEFINED)
Return an Undefined object.

Inherited from LookupBase: globals, lookup_attr, lookup_item, lookup_name

Properties

Inherited from object: __class__

Method Details

undefined(cls, key, owner=UNDEFINED)
Class Method

 
Return an Undefined object.
Parameters:
  • key - the name of the variable
  • owner - the owning object, if the variable is accessed as a member
Overrides: LookupBase.undefined