Plugin note
This functionality is contained within an expression evaluator plugin. As such, it is available only when the corresponding plugin is installed.
Plugin assembly
CSF.Zpt.ExpressionEvaluators.PythonExpressions.dll
Plugin class
CSF.Zpt.ExpressionEvaluators.PythonExpressions.PythonExpressionEvaluator
Expression prefix
python:
TALES 'python' expressions
python:
expressions make it possible to include and evaluate TALES expressions written in
the Python programming language in your ZPT-Sharp documents.
The text following the python:
prefix must be a valid python expression,
such that it may be evaluated if it appeared after a Python return
keyword -
assuming that all of the relevant variables are in-scope.
Python internals
Python expressions internally make use of the IronPython framework to parse and evaluate python expressions.
The Python language version supported is dependant upon IronPython's own support. At present, Python version 2.7 is the maximum language version available.
Modules and imports
At present, no modules are imported for python expressions. There is also no mechanism to specify modules to be imported either.
There are planned changes which will permit the importing of modules. These changes are lined up for a future version of this expression evaluator plugin.
Important note on variable names
In the same way as with C♯ expressions, if the python expressions plugin is installed then all TALES variable names must be valid python variable names. Note that the Python expression evaluator is not one of the plugins installed by default for new installations.
Where the python expression evaluator plugin is installed, it does not matter whether the variables are used within a Python expression or not. If an improperly-named variable is in-scope when a python expression is evaluated then the presence of that variable will corrupt the expression.