adhocracy_core.workflows package

Finite state machines for resources.

interface ISample[source]

Sample workflow.

class ACLLocalRolesState(acl: list=None, local_roles: dict=None, **kw)[source]

Bases: dict

Workflow state setting acl and adding local_roles.

acl = None

acl set for context

local_roles = None

adhocracy_core.schema.LocalRoles added to local_roles of context.

class ACLLocalRolesWorkflow(initial_state, type, name='', description='')[source]

Bases: substanced.workflow.Workflow

Workflow using ACLLocalRolesState to setup states.

get_next_states(context, request: <InterfaceClass pyramid.interfaces.IRequest>) → list[source]

Get states you can trigger a transition to.

update_acl(context) → list[source]

Reset the local permission acl for context.

update_workflow_state_acls(context: <InterfaceClass adhocracy_core.interfaces.IPool>, registry: pyramid.registry.Registry)[source]

Update acl of current workflow state for all resources.

add_workflow(registry: pyramid.registry.Registry, workflow_asset: str, name: str)[source]

Create and add workflow to registry.

Parameters:
  • registry (Registry) – registry to register the workflow and store meta data.
  • workfow_asset – yaml asset file to import the workflow metadata. The data schema is adhocracy_core.workflows.schemas.Workflow.
  • name (str) – identifier for the workflow
Raises:

adhocracy_core.exceptions.ConfigurationError – if the validation for cstruct or the sanity checks in class:substanced.workflow.Workflow fail.

add_workflow_directive(config, workflow: str, name: str)[source]

Create add_workflow pyramid config directive.

Example usage:

config.add_workflow('mypackage:myworkflow.yaml', 'myworkflow)
transition_to_states(context, states: [<class 'str'>], registry: pyramid.registry.Registry, reset=False)[source]

Initialize workflow if needed and do transitions to the given states.

Raises:substanced.workflow.WorkflowError – if transition is missing to do transitions to states.
match_permission(acm, state, permission)[source]

Create a function matching a permission in an ACM.

The function can be used as matcher with the transform function of pyrsistent when transforming an existing ACM to select a specific permission to change.

includeme(config)[source]

Include workflows and add ‘add_workflow’ config directive.