Open source cms for mobile and desktop websites

nive.workflow

nive Workflow implementation

Workflows can be used to define application specific constraints based upon context, users and groups, states and actions.

Process

The workflow process includes the states and transitions and provides most the api. It is possible to define more than one process in the system.

The process is stored as context.meta.pool_wfp.

State

Describes the current contexts state in the workflow process. Each state defines possible actions without calling transitions and is used to define the start and end point of a transition. (In some workflow systems the state is called activity)

The process is stored as context.meta.pool_wfa.

Transition

Links two states and defines the triggering action and security restraints. A transition is looked up and processed by calling process.Action().

Action

An application defined string to describe an action. Default actions used in the cms are: add, remove, create, duplicate, edit, delete, commit, reject

class nive.workflow.WfProcessConf(copyFrom=None, **values)

Workflow process configuration class. The workflow process configuration defines a single workflow to be linked to objects. The WfProcessConf has to be registered as module with the application. Each application can handle any number of workflows.

Values

*id :          Ascii used as name to load this process
*context :     Dotted python name or class reference used as factory.
states :       workflow states
entryPoint :   state id of entry point. default `start`.
transitions :  workflow transitions to connect states 
apply   :      List of interfaces the workflow is registered for. 

name :         Title (optional).
description :  Description (optional).

Call WfConf().test() to verify configuration values.

Interface: IWfProcessConf

class nive.workflow.WfStateConf(copyFrom=None, **values)

Workflow state configuration class. A workflow state defines the current elements position in the workflow process. States are used as start and endpoint for transitions but can also have a list of actions (state.actions) enabled without calling transitions. By default the startpoint in a workflow process is a state with id = ‘start’.

Workflow state configurations are handled by the workflow process they are linked to, not by the cms application. To include states use workflowConf.states and not applicationConf.modules.

Values

*id :          Ascii used as name to load this process
*context :     Dotted python name or class reference used as factory.
actions :      list of allowed actions without calling transitions

name :         Title (optional).
description :  Description (optional).

Call WfStateConf().test() to verify configuration values.

Interface: IWfStateConf

class nive.workflow.WfTransitionConf(copyFrom=None, **values)

Workflow transition configuration class. Use transitions to define possible actions connecting states including security restraints, triggering action(s), and callable fuctions to be executed with the transition.

Workflow transition configurations are handled by the workflow process they are linked to, not by the cms application. To include transistions use workflowConf.transistions and not applicationConf.modules.

Values

*id :          Ascii used as name to load this process
*context :     Dotted python name or class reference used as factory.
fromstate :    state id startpoint of this transition
tostate :      state id endpoint of this transition
roles :        allow the following roles
actions :      actions initiating the transition
conditions :   callables to be called with transition, obj, user on Allowed()
execute :      callables to be executed with this transition
    
values :       custom configuration values passed to callables
name :         Title (optional).
description :  Description (optional).

Callables to be included as condition or execute use the following parameters:

def function_name(transition, context, user, values):
result = True return result

function_name(transition=self, context=context, user=user)

Call WfTransitionConf().test() to verify configuration values.

Interface: IWfTransitionConf

exception nive.workflow.WorkflowNotAllowed
class nive.workflow.Process(configuration, app)

Workflow process implementation

Allow(action, context, user, transition=None)

Checks if the action can be executed. Unlike Action() this function does raise an exception.

parameters

action: the action as string to be executed
context: the context object
user: the current user
transition: transition id. checks this transition only.

returns True/False

Action(action, context, user, transition=None)

Execute the action for current state, context and user.

parameters

action: the action as string to be executed
context: the context object
user: the current user
transition: transition id. checks this transition only.

raises WorkflowNotAllowed

PossibleTransitions(state, action='', transition='', context=None, user=None)

Returns a list of possible transitions

  • if user is set, only transitions for the user are returned
  • if action is set, only transitions for the action are returned
  • if transition is set, only this transition is returned if multiple found for action

parameters

state: state id
action: action name or empty string
transition: transition id or empty string
context: obj to check the transitions
user: check for user name

returns list

GetObjInfo(context, user, extended=True)

Returns workflow information for the current context. If extended = True state and transitions are included too. Otherwise they will be None.

Included values: id, name, process, context, user, state, transitions

parameters

context: the context object
user: the current user
extended: lookup and include state and transitions

returns dict

GetObjState(context)

Returns contexts state as object.

GetTransition(transitionID)

Look up the transition with given id.

returns transition object or None.

GetState(stateID)

Look up the state with given id.

returns state object or None.

© 2013 Nive GmbH