collective.multiworkflow.indexers#

The workflow_states catalog index.

One KeywordIndex describes an object's whole workflow chain, so a site gains no further indexes as behaviors contribute more workflows. Each entry reads <workflow-id>|<state-id>, and the entries are in chain order — the workflow configured for the type, the one driving review_state, is always first.

The same name is also the state_variable an additional workflow should adopt, and that is not cosmetic. WorkflowTool._reindexWorkflowVariables reindexes exactly the indexes named after the chain's workflow variables, so a workflow using this name keeps the index fresh with no help from us; reindex_workflow_states() covers the ones that keep a state variable of their own. Sharing the name across workflows is safe because DCWorkflow keys its status records by workflow id, not by variable name.

What the catalog stores is always workflow_states() and never the workflow variable that happens to share its name: plone.indexer's wrapper consults IIndexer adapters before workflow variables.

collective.multiworkflow.indexers.STATE_SEPARATOR = '|'#

Separates the workflow id from the state id within one indexed value. Neither id can contain it — both are Zope ids.

collective.multiworkflow.indexers.WORKFLOW_STATES = 'workflow_states'#

Name of the index, of the metadata column, and the state_variable an additional workflow should adopt.

collective.multiworkflow.indexers.format_state(workflow_id: str, state_id: str) str[source]#

Build one indexed value out of a workflow id and a state id.

Parameters:
  • workflow_id -- id of the workflow the state belongs to.

  • state_id -- id of the state that workflow is in.

Returns:

the value as the catalog holds it.

collective.multiworkflow.indexers.parse_state(value: str) tuple[str, str][source]#

Split one indexed value back into its workflow id and state id.

Parameters:

value -- a value as format_state() produced it.

Returns:

the workflow id and the state id.

Raises:

ValueError -- if the value carries no separator.

collective.multiworkflow.indexers.reindex_workflow_states(obj: Any, event: Any) None[source]#

Keep the index fresh for workflows with a state variable of their own.

Right after this event, WorkflowTool._invokeWithNotification reindexes every index named after one of the chain's workflow variables. When some workflow in the chain drives WORKFLOW_STATES that already covers this index, and reindexing anyway would recompute the object's entire metadata record a second time — ZCatalog rebuilds every column on a partial reindex, not just the ones named in idxs.

So the handler only acts when nothing else will: for a chain whose workflows all keep bespoke state variables, which is what any workflow written before this index existed does.

Parameters:
  • obj -- the object that transitioned.

  • event -- the IAfterTransitionEvent being handled; unused.