author | Denis Laxalde <denis.laxalde@logilab.fr> |
Mon, 30 Nov 2015 11:09:51 +0100 | |
changeset 10939 | b30c2f49da57 |
parent 10495 | 5bd914ebf3ae |
child 11963 | 64ecd4d96ac7 |
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 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5400
diff
changeset
|
11 |
A workflow describes how certain entities have to evolve between different |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5400
diff
changeset
|
12 |
states. Hence we have a set of states, and a "transition graph", i.e. a set of |
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5400
diff
changeset
|
13 |
possible transitions from one state to another state. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
14 |
|
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5400
diff
changeset
|
15 |
We will define a simple workflow for a blog, with only the following two states: |
7632
3c9dfc6e820b
[book] fix some rest/sphinx errors
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
6880
diff
changeset
|
16 |
`submitted` and `published`. You may want to take a look at :ref:`TutosBase` if |
6880
4be32427b2b9
[book] fixes some references and other doc construction pbs
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
5400
diff
changeset
|
17 |
you want to quickly setup an instance running a blog. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
18 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
19 |
Setting up a workflow |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
20 |
--------------------- |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
21 |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
22 |
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
|
23 |
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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
28 |
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
|
29 |
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
|
30 |
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
|
31 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
32 |
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
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
38 |
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
|
39 |
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
|
40 |
`cubicweb.schema.WorkflowableEntityType`. |
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
41 |
|
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 |
About our example of BlogEntry, we must have: |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
44 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
45 |
.. sourcecode:: python |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
46 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
47 |
from cubicweb.schema import WorkflowableEntityType |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
48 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
49 |
class BlogEntry(WorkflowableEntityType): |
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
50 |
... |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
51 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
52 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
53 |
Creating states, transitions and group permissions |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
54 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
55 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
56 |
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
|
57 |
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
|
58 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
59 |
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
|
60 |
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
|
61 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
62 |
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
|
63 |
``Transition`` which are standard *CubicWeb* entity types. |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
64 |
|
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
65 |
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
|
66 |
to ``migration/postcreate.py``: |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
67 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
68 |
.. sourcecode:: python |
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
69 |
|
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
70 |
_ = unicode |
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 |
moderators = add_entity('CWGroup', name=u"moderators") |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
73 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
74 |
This adds the `moderators` user group. |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
75 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
76 |
.. sourcecode:: python |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
77 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
78 |
wf = add_workflow(u'blog publication workflow', 'BlogEntry') |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
79 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
80 |
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
|
81 |
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
|
82 |
value). |
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
83 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
84 |
.. sourcecode:: python |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
85 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
86 |
submitted = wf.add_state(_('submitted'), initial=True) |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
87 |
published = wf.add_state(_('published')) |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
88 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
89 |
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
|
90 |
'submitted', and the other with name 'published'. |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
91 |
|
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
92 |
``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
|
93 |
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
|
94 |
initial state of the entity type. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
95 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
96 |
.. sourcecode:: python |
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
97 |
|
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
98 |
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
|
99 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
100 |
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
|
101 |
`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
|
102 |
created before. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
103 |
|
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
104 |
``add_transition`` expects |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
105 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
106 |
* 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
|
107 |
* 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
|
108 |
* the target state of the transition, |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
109 |
* and the permissions |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
110 |
(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
|
111 |
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
|
112 |
|
3322
a522f86ab617
[D] book: define a workflow
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
2539
diff
changeset
|
113 |
.. sourcecode:: python |
1714
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 |
checkpoint() |
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
116 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
117 |
.. note:: |
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5394
diff
changeset
|
118 |
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
|
119 |
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
|
120 |
identified by the i18n catalog scripts. |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
121 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
122 |
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
|
123 |
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
|
124 |
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
|
125 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
126 |
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
|
127 |
|
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
|
128 |
* `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
|
129 |
* `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
|
130 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
131 |
|
10495
5bd914ebf3ae
[doc] fix warnings/errors in doc build
Julien Cristau <julien.cristau@logilab.fr>
parents:
10491
diff
changeset
|
132 |
.. image:: ../../../images/03-transitions-view_en.png |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
133 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
134 |
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
|
135 |
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
|
136 |
defined by the workflow. |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
137 |
|
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
|
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
142 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
143 |
Two bits of warning |
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
144 |
~~~~~~~~~~~~~~~~~~~ |
1714
a721966779be
new book layout, do not compile yet
sylvain.thenault@logilab.fr
parents:
diff
changeset
|
145 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
146 |
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
|
147 |
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
|
148 |
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
|
149 |
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
|
150 |
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
|
151 |
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
|
152 |
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
|
153 |
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
|
154 |
setup. |
2172
cf8f9180e63e
delete-trailing-whitespace
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
1714
diff
changeset
|
155 |
|
3560
7d76775f965d
fixlets on the workflow chapter
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
3322
diff
changeset
|
156 |
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
|
157 |
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
|
158 |
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
|
159 |
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
|
160 |
appropriate interface to define your application workflow. |