work in progress: classification quality workflow
git-svn-id: svn://svn.cy55.de/Zope3/src/loops/trunk@2526 fd906abe-77d9-0310-91a1-e0d9ade77398
This commit is contained in:
parent
e7b83a83ad
commit
5272371cc1
4 changed files with 73 additions and 3 deletions
|
@ -23,14 +23,16 @@ First we set up a loops site with basic and example concepts and resources.
|
|||
Stateful Objects
|
||||
================
|
||||
|
||||
A simple publishing workflow
|
||||
----------------------------
|
||||
|
||||
Let's start with registering the states definitions and adapters needed.
|
||||
The states definition (aka 'workflow') is registered as a utility; for
|
||||
making an object statful we'll use an adapter.
|
||||
|
||||
>>> from cybertools.stateful.interfaces import IStatesDefinition, IStateful
|
||||
>>> from cybertools.stateful.publishing import simplePublishing
|
||||
>>> component.provideUtility(simplePublishing, IStatesDefinition,
|
||||
... name='loops.simple_publishing')
|
||||
>>> component.provideUtility(simplePublishing(), name='loops.simple_publishing')
|
||||
|
||||
>>> from loops.organize.stateful.base import SimplePublishable
|
||||
>>> component.provideAdapter(SimplePublishable, name='loops.simple_publishing')
|
||||
|
@ -59,6 +61,23 @@ not just kept in the adapter.
|
|||
'published'
|
||||
|
||||
|
||||
Controlling classification quality
|
||||
----------------------------------
|
||||
|
||||
>>> from loops.organize.stateful.quality import classificationQuality
|
||||
>>> component.provideUtility(classificationQuality(),
|
||||
... name='loops.classification_quality')
|
||||
>>> from loops.organize.stateful.quality import ClassificationQualityCheckable
|
||||
>>> component.provideAdapter(ClassificationQualityCheckable,
|
||||
... name='loops.classification_quality')
|
||||
|
||||
>>> qcheckedDoc01 = component.getAdapter(doc01, IStateful,
|
||||
... name='loops.classification_quality')
|
||||
>>> qcheckedDoc01.state
|
||||
'unclassified'
|
||||
|
||||
|
||||
|
||||
Fin de partie
|
||||
=============
|
||||
|
||||
|
|
|
@ -45,3 +45,4 @@ class StatefulLoopsObject(Stateful, StatefulAdapter):
|
|||
class SimplePublishable(StatefulLoopsObject):
|
||||
|
||||
statesDefinition = 'loops.simple_publishing'
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
i18n_domain="loops">
|
||||
|
||||
<zope:utility
|
||||
factory="cybertools.stateful.publishing.simplePublishingFactory"
|
||||
factory="cybertools.stateful.publishing.simplePublishing"
|
||||
name="loops.simple_publishing" />
|
||||
|
||||
<zope:adapter
|
||||
|
|
50
organize/stateful/quality.py
Normal file
50
organize/stateful/quality.py
Normal file
|
@ -0,0 +1,50 @@
|
|||
#
|
||||
# Copyright (c) 2008 Helmut Merz helmutm@cy55.de
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
"""
|
||||
Basic implementations for stateful objects and adapters.
|
||||
|
||||
$Id$
|
||||
"""
|
||||
|
||||
from zope.interface import implementer
|
||||
|
||||
from cybertools.stateful.definition import registerStatesDefinition
|
||||
from cybertools.stateful.definition import StatesDefinition
|
||||
from cybertools.stateful.definition import State, Transition
|
||||
from cybertools.stateful.interfaces import IStatesDefinition
|
||||
from loops.organize.stateful.base import StatefulLoopsObject
|
||||
|
||||
|
||||
@implementer(IStatesDefinition)
|
||||
def classificationQuality():
|
||||
return StatesDefinition('classificationQuality',
|
||||
State('unclassified', 'unclassified', ('classify',)),
|
||||
State('classified', 'classified', ('check',)),
|
||||
State('checked', 'checked',
|
||||
('change_classification', 'remove_classification')),
|
||||
Transition('classify', 'classify', 'classified'),
|
||||
Transition('check', 'check', 'checked'),
|
||||
Transition('change_classification', 'change classification', 'classified'),
|
||||
Transition('remove_classification', 'remove classification', 'unclassified'),
|
||||
initialState='unclassified')
|
||||
|
||||
|
||||
class ClassificationQualityCheckable(StatefulLoopsObject):
|
||||
|
||||
statesDefinition = 'loops.classification_quality'
|
Loading…
Add table
Reference in a new issue