collective.multiworkflow.exportimport#
Patches to plone.exportimport, kept together for upstreaming.
plone.exportimport restores an object's workflow state by assigning
obj.workflow_history directly. That fires no transition, so none of the
machinery that keeps workflow variables catalogued ever runs:
WorkflowTool._reindexWorkflowVariables is only reached through
_invokeWithNotification.
review_state escapes the problem because update_review_state performs a
real transition just before. Any other workflow variable does not, and its
index keeps whatever value the object was first catalogued with — which is
exactly the state an additional workflow is in.
Measured on this package's own example content, importing an object whose
membership workflow is active:
object foundation_member_workflow: active
catalog foundation_member_workflow|pending <- stale
The publication state is right either way, so the staleness reads as a correct index rather than a broken one.
The fix belongs upstream, in update_workflow_history. Until it lands there,
this module applies it as a wrapper, in one place, shaped so that the body of
reindex_workflow_variables() can be moved into plone.exportimport
unchanged.
The patch is applied when this subpackage's ZCML is loaded, which the root
configure.zcml does.
- collective.multiworkflow.exportimport.apply_patches() None[source]#
Wrap
update_workflow_historyso it reindexes what it changed.updaters()builds its list by reading the module globals each time it is called, so rebinding the module attribute is enough — no import in plone.exportimport holds an earlier reference to the original.Does nothing when plone.exportimport is absent. It is not a dependency of this package, nor of
Products.CMFPlone; it arrives withplone.distributionin a standard Plone installation.
- collective.multiworkflow.exportimport.reindex_workflow_variables(obj: DexterityContent) DexterityContent[source]#
Reindex the catalog indexes named after the object's workflow variables.
This is the body proposed for plone.exportimport: it names no index of this package's own, and it is a no-op on a site whose content runs a single workflow, because
review_stateis already fresh by the time it runs.Only variables the catalog actually has an index for are reindexed. A workflow declaring a state variable no index is named after is therefore left alone here, as it is everywhere else in Plone.
- Parameters:
obj -- the object whose workflow history was just restored.
- Returns:
the same object, for chaining.