Version 33 (modified by spango <spango@…>, 6 years ago) (diff)


GoFlow: a workflow engine for Django




  • 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/, and the goflow data model generated by modelviz/graphviz). 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',

this diagram is a graphviz dot representation. It has written by hand, but soon, it should be generated.

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:

    'leavedemo.leave',     # the leave application
    'goflow.workflow',     # goflow workflow engine

If you use send_mail application, you should define these:

DEFAULT_FROM_EMAIL = email sender
EMAIL_HOST = smtp server

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

If you use send_mail application, you should define these:

EMAIL_SUBJECT_PREFIX = '[Goflow notification]' file

Starting a workflow instance

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


    (r'^leave/start/(app)/(model)/$', 'goflow.workflow.applications.start_application'),

This above is the simplest way to start: the default process has the same name as app, and the default template used is "start_[model].html".

other usage:

     {'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('goflow.workflow.urls')),

So the workflow engine provides handlers and default templates below:

    (r'^mywork/$', 'goflow.workflow.views.mywork', {'template':'mywork.html'}),
    (r'^otherswork/$', 'goflow.workflow.views.otherswork', {'template':'otherswork.html'}),
    (r'^otherswork/instancehistory/$', 'goflow.workflow.views.instancehistory', {'template':'instancehistory.html'}),
    (r'^myrequests/$', 'goflow.workflow.views.myrequests', {'template':'myrequests.html'}),
    (r'^myrequests/instancehistory/$', 'goflow.workflow.views.instancehistory', {'template':'instancehistory.html'}),
    (r'^mywork/activate/$', 'goflow.workflow.views.activate', {'template':'activate.html'}),
    (r'^mywork/complete/$', 'goflow.workflow.views.complete', {'template':'complete.html'}),
  • mywork: displays the tasks list of the current user
  • ....
  • cron: cron simulation task for timeout management

next soon

Application templates

You can (may) redefine the templates associated with standard workflow views.

For each application, a specific template has to be built. The context available has following variales:

  • form: form (newforms framework)
  • instance: instance object
  • ob: object (application-defined) linked to instance
  • instance_props: properties of instance

The application developper should insert submit input fields when he inserts forms; the application_form handler then will update instance.condition with the value of the submit button pressed.

Attachments (3)

Download all attachments as: .zip