code – Embedding Python code in XML
An XIST module that allows embedding Python code in XML.
- class ll.xist.ns.code.pyexec[source]
Bases:
ll.xist.ns.code._baseWhen converting a
pyexecobject the content of the processing instruction is executed as Python code. Execution is done when the node is converted. When converted such a node will result in an emptyNullnode.These processing instructions will be evaluated and executed in the namespace of the module sandbox (which will be store in the converter context).
- class ll.xist.ns.code.pyeval[source]
Bases:
ll.xist.ns.code._baseThe content of a
pyevalprocessing instruction will be executed when the node is converted as if it was the body of a function, so you can return an expression here. Although the content is used as a function body no indentation is necessary or allowed. The returned value will be converted to a node and this resulting node will be converted.These processing instructions will be evaluated and executed in the namespace of the module sandbox (which will be store in the converter context).
Note that you should not define the symbol
__in any of your XIST processing instructions, as it is used by XIST for internal purposes.- convert(converter)[source]
Evaluates the code as if it was the body of a Python function. The
converterargument will be available under the nameconverteras an argument to the function.