doc/book/en/development/datamodel/define-workflows.rst
author Aurelien Campeas <aurelien.campeas@logilab.fr>
Mon, 05 Oct 2009 19:11:48 +0200
branchstable
changeset 3560 7d76775f965d
parent 3322 a522f86ab617
child 4437 21f2e01fdd6a
permissions -rw-r--r--
fixlets on the workflow chapter
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     2
2539
0f26a76b0348 [doc] some more rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2476
diff changeset
     3
Define a Workflow
0f26a76b0348 [doc] some more rewriting
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2476
diff changeset
     4
=================
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     5
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     6
General
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     7
-------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
     8
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
     9
A workflow describes how certain entities have to evolve between
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    10
different states. Hence we have a set of states, and a "transition graph",
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    11
i.e. a set of possible transitions from one state to another state.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    12
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    13
We will define a simple workflow for a blog, with only the following
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    14
two states: `submitted` and `published`. So first, we create a simple
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    15
*CubicWeb* instance in ten minutes (see :ref:`BlogFiveMinutes`).
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    16
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    17
Set-up a workflow
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    18
-----------------
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    19
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    20
We want to create a workflow to control the quality of the BlogEntry
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    21
submitted on the instance. When a BlogEntry is created by a user
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    22
its state should be `submitted`. To be visible to all, it has to
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    23
be in the state `published`. To move it from `submitted` to `published`,
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    24
we need a transition that we can call `approve_blogentry`.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    25
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    26
A BlogEntry state should not be modifiable by every user.
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    27
So we have to define a group of users, `moderators`, and
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    28
this group will have appropriate permissions to publish a BlogEntry.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    29
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    30
There are two ways to create a workflow: from the user interface, or
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    31
by defining it in ``migration/postcreate.py``. This script is executed
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    32
each time a new ``cubicweb-ctl db-init`` is done.  We strongly
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    33
recommend to create the workflow in ``migration/postcreate.py`` and we
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    34
will now show you how. Read `Two bits of warning`_ to understand why.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    35
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    36
The state of an entity is managed by the `in_state` attribute which
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    37
can be added to your entity schema by inheriting from
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    38
`cubicweb.schema.WorkflowableEntityType`.
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    39
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    40
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    41
About our example of BlogEntry, we must have:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    42
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    43
.. sourcecode:: python
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    44
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    45
  from cubicweb.schema import WorkflowableEntityType
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    46
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    47
  class BlogEntry(WorkflowableEntityType):
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    48
      ...
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    49
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    50
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    51
Create states, transitions and group permissions
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    52
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    53
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    54
The ``postcreate.py`` script is executed in a special environment, adding
2175
16d3c37c5d28 [doc] improvements
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 2172
diff changeset
    55
several *CubicWeb* primitives that can be used.
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    56
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    57
They are all defined in the ``class ServerMigrationHelper``.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    58
We will only discuss the methods we use to create a workflow in this example.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    59
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    60
A workflow is a collection of entities of type ``State`` and of type
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    61
``Transition`` which are standard *CubicWeb* entity types.
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    62
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    63
To define a workflow for BlogDemo, please add the following lines
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    64
to ``migration/postcreate.py``:
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    65
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    66
.. sourcecode:: python
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
    67
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    68
  _ = unicode
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    69
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    70
  moderators = add_entity('CWGroup', name=u"moderators")
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    71
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    72
This adds the `moderators` user group.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    73
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    74
.. sourcecode:: python
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    75
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    76
  wf = add_workflow(u'blog publication workflow', 'BlogEntry')
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    77
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    78
At first, instanciate a new workflow object with a gentle description
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    79
and the concerned entity types (this one can be a tuple for multiple
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    80
value).
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    81
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    82
.. sourcecode:: python
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    83
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    84
  submitted = wf.add_state(_('submitted'), initial=True)
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    85
  published = wf.add_state(_('published'))
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    86
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    87
This will create two entities of type ``State``, one with name
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    88
'submitted', and the other with name 'published'.
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    89
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    90
``add_state`` expects as first argument the name of the state you want
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    91
to create and an optional argument to say if it is supposed to be the
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    92
initial state of the entity type.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    93
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    94
.. sourcecode:: python
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    95
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
    96
  wf.add_transition(_('approve_blogentry'), (submitted,), published, ('moderators', 'managers'),)
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
    97
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    98
This will create an entity of type ``Transition`` with name
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
    99
`approve_blogentry` which will be linked to the ``State`` entities
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   100
created before.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   101
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   102
``add_transition`` expects
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   103
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   104
  * as the first argument: the name of the transition
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
   105
  * then the list of states on which the transition can be triggered,
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   106
  * the target state of the transition,
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   107
  * and the permissions
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   108
    (e.g. a list of user groups who can apply the transition; the user
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   109
    has to belong to at least one of the listed group to perform the action).
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   110
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
   111
.. sourcecode:: python
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   112
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   113
  checkpoint()
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   114
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   115
.. note::
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   116
  Do not forget to add the `_()` in front of all states and transitions names while creating
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   117
  a workflow so that they will be identified by the i18n catalog scripts.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   118
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   119
In addition to the user groups (one of which the user needs to belong
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   120
to), we could have added a RQL condition.  In this case, the user can
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   121
only perform the action if the two conditions are satisfied.
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   122
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   123
If we use an RQL condition on a transition, we can use the following variables:
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   124
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   125
* `%(eid)s`, object's eid
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   126
* `%(ueid)s`, user executing the query eid
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   127
* `%(seid)s`, the object's current state eid
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   128
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   129
3322
a522f86ab617 [D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 2539
diff changeset
   130
.. image:: ../../images/03-transitions-view.en.png
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   131
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   132
You can notice that in the action box of a BlogEntry, the state is now
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   133
listed as well as the possible transitions for the current state
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   134
defined by the workflow.
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   135
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   136
The transitions will only be displayed for users having the right permissions.
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   137
In our example, the transition `approve_blogentry` will only be displayed
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   138
for the users belonging to the group `moderators` or `managers`.
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   139
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   140
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   141
Two bits of warning
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   142
~~~~~~~~~~~~~~~~~~~
1714
a721966779be new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff changeset
   143
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   144
We could perfectly use the administration interface to do these
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   145
operations. It is a convenient thing to do at times (when doing
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   146
development, to quick-check things). But it is not recommended beyond
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   147
that because it is a bit complicated to do it right and it will be
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   148
only local to your instance (or, said a bit differently, such a
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   149
workflow only exists in an instance database). Furthermore, you cannot
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   150
write unit tests against deployed instances, and experience shows it
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   151
is mandatory to have tests for any mildly complicated workflow
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   152
setup.
2172
cf8f9180e63e delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 1714
diff changeset
   153
3560
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   154
Indeed, if you create the states and transitions through the user
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   155
interface, next time you initialize the database you will have to
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   156
re-create all the workflow entities. The user interface should only be
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   157
a reference for you to view the states and transitions, but is not the
7d76775f965d fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents: 3322
diff changeset
   158
appropriate interface to define your application workflow.