Metadata-Version: 2.5
Name: trytond_score_expression
Version: 8.0.0.2
Summary: Score Workflow Engine — Sandboxed Expressions
Author: Clemens Hupka
Maintainer-email: Clemens Hupka <clemens.hupka@backend.at>
License-Expression: GPL-3.0-or-later
License-File: COPYRIGHT
License-File: LICENSE
Keywords: engine,expression,sandbox,score,tryton,workflow
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Environment :: Plugins
Classifier: Framework :: Tryton
Classifier: Topic :: Office/Business
Requires-Python: >=3.10
Requires-Dist: trytond-score<8.1,>=8.0
Requires-Dist: trytond<8.1,>=8.0
Provides-Extra: test
Description-Content-Type: text/x-rst

Score Expression Module
=======================

The ``score_expression`` module adds a sandboxed expression language to
the ``score`` workflow engine.  The engine decides a transition with
PYSON, which covers what a definition usually asks of it; this module is
the escape hatch for the cases PYSON can not express, and it is added
only behind a sandbox.

An expression is parsed, walked and interpreted by the module: it is
never compiled and ``eval`` is never called.  What a definition may write
is an explicit allowlist of node types, the names of a closed symbol
table (``record``, ``context``, ``instance``, ``user``,
``current_date``), the pure functions the module declares, the fields an
attribute names on a record and the parts it names on a date, boolean,
comparison and arithmetic operators, and item access on mappings,
sequences and text.  Imports, lambdas, comprehensions, assignments,
private names (``__class__``, ``__globals__``), attribute access on
anything else than a record or a date and calls to anything but a
declared function are refused where the definition is saved, with a
message that names the construct that was refused.

The length of an expression and the number of nodes of its syntax tree
are bounded, so that a definition can not be used to cost the server more
than the values it already holds: arithmetic works on numbers alone,
which is what keeps a definition from building a text whose size it does
not bound.

Two things are added to a definition.  A guard of the kind *Expression*
decides a transition with an expression instead of a PYSON condition or a
method, and an action of the kind *Set Field* writes the value of an
expression into a field of the record the workflow drives, while an
action of the kind *Expression* publishes that value in the context of
the run, where the guards and the actions of the transitions that follow
read it.  The base module remains PYSON-only: it does not depend on this
one, and a deployment that does not install it never reads an expression.
