Expression Implementations

Basic Page Template expression types.

Expression objects are created by the ExpressionEngine (they must have previously been registered with registerType()). The expression object itself is a callable object taking one argument, econtext, which is the local expression namespace.

zope.tales.expressions.simpleTraverse(object, path_items, econtext)[source]

Traverses a sequence of names, first trying attributes then items.

class zope.tales.expressions.SubPathExpr(path, traverser, engine)[source]

Bases: object

Implementation of a single path expression.

class zope.tales.expressions.PathExpr(name, expr, engine, traverser=<function simpleTraverse>)[source]

Bases: object

One or more subpath expressions, separated by |.

class zope.tales.expressions.StringExpr(name, expr, engine)[source]

Bases: object

An expression that produces a string.

Sub-sequences of the string that begin with $ are interpreted as path expressions to evaluate.

class zope.tales.expressions.NotExpr(name, expr, engine)[source]

Bases: object

An expression that negates the boolean value of its sub-expression.

class zope.tales.expressions.DeferExpr(name, expr, compiler)[source]

Bases: object

An expression that will defer evaluation of the sub-expression until necessary, preserving the execution context it was created with.

This is useful in tal:define expressions:

<div tal:define="thing defer:some/path">
  <!-- some/path is only evaluated if condition is true -->
  <span tal:condition="condition" tal:content="thing"/>
class zope.tales.expressions.LazyWrapper(expr, econtext)[source]

Bases: zope.tales.expressions.DeferWrapper

Wrapper for lazy: expression

class zope.tales.expressions.LazyExpr(name, expr, compiler)[source]

Bases: zope.tales.expressions.DeferExpr

An expression that will defer evaluation of its sub-expression until the first time it is necessary.

This is like DeferExpr, but caches the result of evaluating the expression.

class zope.tales.expressions.SimpleModuleImporter[source]

Bases: object

Minimal module importer with no security.

class zope.tales.pythonexpr.PythonExpr(name, expr, engine)[source]

Bases: object

Evaluates a python expression by calling eval() after compiling it with compile().

  • expr (str) – The Python expression.
  • engine (ExpressionEngine) – The expression compiler that is creating us.