author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Fri, 23 Apr 2010 20:06:04 +0200 | |
branch | stable |
changeset 5400 | b7ab099b128a |
parent 5394 | 105011657405 |
child 6880 | 4be32427b2b9 |
permissions | -rw-r--r-- |
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 |
|
4936
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4437
diff
changeset
|
3 |
.. _Workflow: |
a4b772a0d801
Fixed some of the documentation warnings when building the book with sphinx.
Adrien Chauve <adrien.chauve@logilab.fr>
parents:
4437
diff
changeset
|
4 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
5 |
Defining a Workflow |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
6 |
=================== |
1714
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 |
General |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
9 |
------- |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
10 |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
11 |
A workflow describes how certain entities have to evolve between |
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
12 |
different states. Hence we have a set of states, and a "transition |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
13 |
graph", i.e. a set of possible transitions from one state to another |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
14 |
state. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
15 |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
16 |
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
|
17 |
two states: `submitted` and `published`. So first, we create a simple |
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
18 |
|cubicweb| instance in five minutes (see :ref:`BlogFiveMinutes`). |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
19 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
20 |
Setting up a workflow |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
21 |
--------------------- |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
22 |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
23 |
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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
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
|
28 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
29 |
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
|
30 |
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
|
31 |
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
|
32 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
39 |
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
|
40 |
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
|
41 |
`cubicweb.schema.WorkflowableEntityType`. |
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
42 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
43 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
44 |
About our example of BlogEntry, we must have: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
45 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
46 |
.. sourcecode:: python |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
47 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
48 |
from cubicweb.schema import WorkflowableEntityType |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
49 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
50 |
class BlogEntry(WorkflowableEntityType): |
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
51 |
... |
1714
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 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
54 |
Creating states, transitions and group permissions |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
55 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
56 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
57 |
The :mod:`postcreate` script is executed in a special environment, |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
58 |
adding several |cubicweb| primitives that can be used. |
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
59 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
60 |
They are all defined in the :class:`ServerMigrationHelper` class. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
61 |
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
|
62 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
63 |
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
|
64 |
``Transition`` which are standard *CubicWeb* entity types. |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
65 |
|
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
66 |
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
|
67 |
to ``migration/postcreate.py``: |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
68 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
69 |
.. sourcecode:: python |
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
70 |
|
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
71 |
_ = unicode |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
72 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
73 |
moderators = add_entity('CWGroup', name=u"moderators") |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
74 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
75 |
This adds the `moderators` user group. |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
76 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
77 |
.. sourcecode:: python |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
78 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
79 |
wf = add_workflow(u'blog publication workflow', 'BlogEntry') |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
80 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
81 |
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
|
82 |
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
|
83 |
value). |
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
84 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
85 |
.. sourcecode:: python |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
86 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
87 |
submitted = wf.add_state(_('submitted'), initial=True) |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
88 |
published = wf.add_state(_('published')) |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
89 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
90 |
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
|
91 |
'submitted', and the other with name 'published'. |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
92 |
|
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
93 |
``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
|
94 |
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
|
95 |
initial state of the entity type. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
96 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
97 |
.. sourcecode:: python |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
98 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
99 |
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
|
100 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
101 |
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
|
102 |
`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
|
103 |
created before. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
104 |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
105 |
``add_transition`` expects |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
106 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
107 |
* 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
|
108 |
* 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
|
109 |
* the target state of the transition, |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
110 |
* and the permissions |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
111 |
(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
|
112 |
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
|
113 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
114 |
.. sourcecode:: python |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
115 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
116 |
checkpoint() |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
117 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
118 |
.. note:: |
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
119 |
Do not forget to add the `_()` in front of all states and |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
120 |
transitions names while creating a workflow so that they will be |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
121 |
identified by the i18n catalog scripts. |
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 |
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
|
124 |
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
|
125 |
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
|
126 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
127 |
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
|
128 |
|
4437
21f2e01fdd6a
update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3560
diff
changeset
|
129 |
* `X`, the entity on which we may pass the transition |
21f2e01fdd6a
update exemples using the 3.6 api and add/fix some sections (schema, vreg, talk about CW_MODE in concepts...). So much to do :'(
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
3560
diff
changeset
|
130 |
* `U`, the user executing that may pass the transition |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
131 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
132 |
|
5388
9167751463d4
[doc/book] rename images with non suffix dots to please latex
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
4936
diff
changeset
|
133 |
.. image:: ../../images/03-transitions-view_en.png |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
134 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
135 |
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
|
136 |
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
|
137 |
defined by the workflow. |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
138 |
|
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
|
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 |
Two bits of warning |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
145 |
~~~~~~~~~~~~~~~~~~~ |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
146 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
147 |
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
|
148 |
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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
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
|
154 |
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
|
155 |
setup. |
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
156 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
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
|
161 |
appropriate interface to define your application workflow. |