Core concepts

Flow and Flow Tasks

django-viewflow introduces Flow classes as the single place to configure and setup task, dependenices, persistance, user rights checking and interface setup.

Each flow should be subclass of viewflow.base.Flow.

class viewflow.base.Flow

Base class for flow definition

Parameters:
  • process_cls – Defines model class for Process
  • task_cls – Defines model class for Task
  • management_form_cls – Defines form class for task state tracking over GET requests
  • lock_impl – Locking implementation for flow
urls

Provides ready to include urlpatterns required for this flow

Each flow could contains several flow tasks. Flow task represents declaration of what should be performed on this step, and what next steps should be activated.

Flow does not have specific declaration of task transitions, and all logic of task activation belongs to the task itself. This makes Flow code close to well-known BPMN notation, and helps to convert it to BPMN and vise versa.

Flow class should have at least one of viewflow.flow.Start task and at least one of viewflow.flow.End

class viewflow.flow.Node(activation_cls=None, **kwargs)

Base class for flow task.

Parameters:
  • task_type – Human readable task type
  • activation_cls – Activation implementation specific for this node
activate(prev_activation, token)

Creates task activation.

See Flow Tasks documentation for list of all available tasks.

Activation

class viewflow.activation.Activation(*args, **kwargs)

Base class for flow task activations.

Activation responsible for flow task state management and persistance

Each activation status chages restricted by a simple finite state automata

Base class enshures that all tasks could be undone or cancelled.

classmethod activate(flow_task, prev_activation, token)

Instantiate and persist new flow task.

Models

django-viewflow provides base model for tracking the process state. In most cases you should subclass viewflow.models.Process to add additional data fields.

In case if you need to track some execution info or add logging, you can do it by extending viewflow.models.Task

class viewflow.models.Task(id, flow_task, flow_task_type, status, created, started, finished, token, process, owner, external_task_id, owner_permission, comments)
class viewflow.models.Process(id, flow_cls, status, created, finished)

Views

Urls

viewflow.base.Flow collects all urls required by View tasks, you just have to include it in urlpatters

urlpatterns = patterns('',
      url(r'^myflow/', include(MyFlow.instance.urls)))