collective.multiworkflow.declaration

collective.multiworkflow.declaration#

Registration API for workflow contributions.

A behavior declares the workflows it contributes by registering a subscription adapter on its own marker interface. This module provides the helper used to write such a factory, the lookup that collects every contribution an object makes, and the lookup of the label a workflow is shown under.

collective.multiworkflow.declaration.collect_contributions(context: Any) → tuple[str, ...][source]#

Collect the workflow ids every participating marker contributes.

Contributions are returned in subscriber registration order, deduplicated, keeping the first occurrence of each id.

Parameters:

context -- the content object whose contributions are collected.

Returns:

the contributed workflow ids, deduplicated and ordered.

collective.multiworkflow.declaration.contributes(marker: type[<InterfaceClass zope.interface.Interface>], *workflow_ids: str) → Callable[[Any], tuple[str, ...]][source]#

Build a subscription adapter factory contributing workflow_ids.

Most callers want the ZCML directive instead, which wraps this and validates the marker while the configuration is read:

<plone:additionalworkflows
    marker=".interfaces.IFoundationMember"
    workflows="foundation_member_workflow"
    />

This function stays public for the cases ZCML cannot express — building a contribution from configuration read at start-up, say — where the factory is registered by hand and provides IAdditionalWorkflowsFor.

Parameters:
  • marker -- the behavior marker interface the factory adapts.

  • workflow_ids -- ids of the workflows this marker contributes.

Returns:

an adapter factory returning workflow_ids.

collective.multiworkflow.declaration.workflow_label(workflow: Any) → str[source]#

Name a workflow the way the user interface should show it.

A label declared on <plone:additionalworkflows /> wins; otherwise the workflow's own title is used. A declared label is a message id in the i18n domain of the ZCML file declaring it, so translate the result before showing it.

Parameters:

workflow -- the workflow definition to name.

Returns:

the declared label, or the workflow's title when none is declared.