code – Embedding Python code in XML

An XIST module that allows embedding Python code in XML.

class ll.xist.ns.code.pyeval(*content)[source]

Bases: ll.xist.ns.code._base

The content of a pyeval processing 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 neccessary 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 funtion. The converter argument will be available under the name converter as an argument to the function.

class ll.xist.ns.code.pyexec(*content)[source]

Bases: ll.xist.ns.code._base

When converting a pyexec object 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 empty Null node.

These processing instructions will be evaluated and executed in the namespace of the module sandbox (which will be store in the converter context).