About state variables and review_state#
Every workflow records the state of an object in a variable of its own, named by its state_variable setting.
Plone's publication workflow names it review_state, and so much of Plone reads that name that it is easy to mistake it for the name of the concept rather than the name of one workflow's variable.
This page explains why an additional workflow must not use it, and why this package recommends that additional workflows share one other name instead.
Status is keyed by workflow, not by variable#
DCWorkflow stores an object's workflow status in a mapping keyed by workflow id. Each workflow's record is separate, and each record holds that workflow's own state under that workflow's own variable name.
Two consequences follow, and the second one surprises people.
Two workflows in a chain cannot corrupt each other's stored state, whatever they call their variables.
Two workflows in a chain may therefore use the same variable name without colliding, because the name is only ever read inside one workflow's record.
Why review_state must stay with the publication workflow#
Not because of storage, then, but because of everything reading it.
review_state is the name the catalog indexes, the name plone.api.content.get_state returns, the name the sharing and publication user interface acts on, and the name WorkflowTool.getInfoFor resolves when no workflow is specified—by walking the chain and answering with the first workflow that declares it.
An additional workflow declaring review_state therefore does not overwrite the publication workflow's state.
It does something harder to debug: it makes the answer to an unqualified question depend on chain order.
Content appears published because a membership workflow happens to have a state of that name, or a publication transition disappears from a menu because another workflow answered first.
So the rule is not a matter of taste.
An additional workflow declaring review_state is a bug, and the only reliable way to keep review_state meaning what it has always meant is to leave it to the workflow that owns it.
What a reader should take away#
review_stateis one workflow's variable, not a general concept.An additional workflow must declare its own state variable, and
workflow_statesis the one to declare.Reading a specific workflow's state means naming that workflow, which is what the Python API and the
chainkey of the REST API both make possible.
See also
How to write a workflow that composes for the steps, and Catalog index for what the index holds.