genshi.template.eval.StrictLookup

Package genshi :: Package template :: Module eval :: Class StrictLookup |

# Class StrictLookup

    object --+
             |
    LookupBase --+
                 |
                StrictLookup

Strict variable lookup mechanism for expressions.

Referencing an undefined variable using this lookup style will immediately raise an `UndefinedError`:

    >>> expr = Expression('nothing', lookup='strict')
    >>> expr.evaluate({})
    Traceback (most recent call last):
        ...
    UndefinedError: "nothing" not defined

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

    >>> expr = Expression('something.nil', lookup='strict')
    >>> expr.evaluate({'something': dict()})
    Traceback (most recent call last):
        ...
    UndefinedError: {} has no member named "nil"

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) Raise an `UndefinedError` immediately. |
Inherited from `LookupBase`: `globals`, `lookup_attr`, `lookup_item`, `lookup_name`

Properties
Inherited from `object`: `__class__`

Method Details

### undefined(cls, key, owner=UNDEFINED) Class Method |
Raise an `UndefinedError` immediately. Parameters: `key` - the name of the variable `owner` - the owning object, if the variable is accessed as a member Overrides: LookupBase.undefined