Version 10 (modified by goflow@…, 9 years ago) (diff)


GoFlow: a workflow engine for Django


  • 2007-09-23: GoFlow is now available as a django contrib
  • FAQ


  • contact: goflow(at)

The Leave workflow application

Follow instructions in the install.txt file included in the goflow distribution. You can then play with the leave demo application (available online too). You will find here some details of the leave application implementation.

defining the workflow process

First, let's take a look at the process definition; the process is stored in the database, by using entities like Process, Activities, Transitions, Application (see workflow/ In the leavedemo project, the process is dumped with the django dumpdata utility, and provided as a fixture. Typically, when you want to define a process, you will use the admin web console.

So, the process is the following:

below, the process translated as django entities, with a python syntax (it is not a real code, it's just more readable by humans):

Process(title='leave', begin='Begin', end='End')

Activity(title='Begin', application='checkstatus',
         splitMode='xor', roles=('secretary',))

Activity(title='Approval', application='approvalform',
         splitMode='xor', roles=('secretary',))

Activity(title='Refinement', application='refine',
         joinMode='xor', splitMode='xor')

Activity(title='UpdateHR', application='hrform',

Activity(title='End', application='finalinfo',
         joinMode='xor', roles=('secretary',),

           input = 'Begin', output='Approval',
           condition="instance.condition=='OK: Forward to supervisor'")

           input = 'Begin', output='Refinement',
           condition="instance.condition=='Denied: Back to requester'")

           input = 'Approval', output='UpdateHR',
           condition="instance.condition=='OK: Forward to secretary'")

           input = 'Approval', output='Refinement',
           condition="instance.condition=='Denied: Back to requester'")

           input = 'UpdateHR', output='End')

           input = 'Refinement', output='End',
           condition="instance.condition=='Withdraw request'")

           input = 'Refinement', output='Begin',

Some definitions:
A transition is a path from an Activity to another one.
An Activity is a task that a person (or an automatic process) with a specific role must achieve: it is linked to an Application which is typically an URL declared in the file.
A push application is a handler that return a user, given the context of process instance (in fact the parameter of the handler is a workitem, we will see this later)

settings file

standard settings

First, tell Django you want to use the workflow engine:

    'django.contrib.workflow',    # uses the workflow engine
    #'contrib.workflow',          # alternative if workflow engine is not installed as contrib
    'leavedemo.leave',            # the leave application

specific settings

WF_APPS_PREFIX = 'leavedemo'

This is the url prefix for workflow application definition; for example, in the workflow definition the application app1 is mapped on the url /leavedemo/app1

WF_PUSH_APPS_PREFIX = 'leavedemo.leave.pushapplications'

this is the module containing the push applications functions; for example, the push application pushapp1 is a function defined as following in the leavedemo/leave/ module:

def pushapp1(workitem):
    return aUser file

Starting a workflow instance

the start_application is a handler that display a form used to create an instance of the workflow process:


     {'process_name':'leave', 'form_class':RequestForm, 'template':'start_leave.html'}),

next soon ...

workflow urls

Some urls are workflow standard tasks, managed by the engine itself; like CRUD urls managed by admin, the workflow standard tasks are available with the following line in the file:

    (r'^leavedemo/', include('django.contrib.workflow.urls')),

So the workflow engine provides handlers and default templates below:

    (r'^mywork/$', 'django.contrib.workflow.views.mywork', {'template':'mywork.html'}),
    (r'^otherswork/$', 'django.contrib.workflow.views.otherswork', {'template':'otherswork.html'}),
    (r'^otherswork/instancehistory/$', 'django.contrib.workflow.views.instancehistory', {'template':'instancehistory.html'}),
    (r'^myrequests/$', 'django.contrib.workflow.views.myrequests', {'template':'myrequests.html'}),
    (r'^myrequests/instancehistory/$', 'django.contrib.workflow.views.instancehistory', {'template':'instancehistory.html'}),
    (r'^mywork/activate/$', 'django.contrib.workflow.views.activate', {'template':'activate.html'}),
    (r'^mywork/complete/$', 'django.contrib.workflow.views.complete', {'template':'complete.html'}),

mywork: displays the tasks list of the current user

next soon

Attachments (3)

Download all attachments as: .zip

Back to Top