process: Python3 fixes
This commit is contained in:
parent
8037ac38be
commit
f9a3326ec7
3 changed files with 14 additions and 58 deletions
|
@ -1,8 +1,6 @@
|
|||
Business Process Management
|
||||
===========================
|
||||
|
||||
($Id$)
|
||||
|
||||
We start with the definition of a simple process:
|
||||
|
||||
startActivity --> n01 --> endActivity
|
||||
|
@ -28,15 +26,15 @@ process' end activity:
|
|||
So let's now associate an action handler with the process' activitys:
|
||||
|
||||
>>> from zope.component import provideAdapter, adapts
|
||||
>>> from zope.interface import implements
|
||||
>>> from zope.interface import implementer
|
||||
>>> from cybertools.process.interfaces import IActivity, IActionHandler
|
||||
|
||||
>>> class DummyHandler(object):
|
||||
... implements(IActionHandler)
|
||||
... adapts(IActivity)
|
||||
... def __init__(self, context): pass
|
||||
... def handle(self, execution):
|
||||
... print 'working.'
|
||||
... print('working.')
|
||||
>>> DummyHandler = implementer(IActionHandler)(DummyHandler)
|
||||
|
||||
>>> provideAdapter(DummyHandler)
|
||||
>>> execution = process.execute()
|
||||
|
|
|
@ -1,38 +1,18 @@
|
|||
#
|
||||
# Copyright (c) 2006 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
|
||||
#
|
||||
# cybertools.process.definition
|
||||
|
||||
"""
|
||||
Process definitions.
|
||||
|
||||
$Id$
|
||||
""" Process definitions.
|
||||
"""
|
||||
|
||||
from zope import component
|
||||
from zope.interface import implements
|
||||
from zope.interface import implementer
|
||||
from cybertools.process.interfaces import IActivity, IProcess
|
||||
from cybertools.process.interfaces import IActionHandler
|
||||
from cybertools.process.execution import Execution
|
||||
|
||||
|
||||
@implementer(IActivity)
|
||||
class Activity(object):
|
||||
|
||||
implements(IActivity)
|
||||
|
||||
def __init__(self, name=u'', title=u'', handlerName=''):
|
||||
self._successors = set()
|
||||
self._handlerName = handlerName
|
||||
|
@ -61,10 +41,9 @@ class Activity(object):
|
|||
return execution
|
||||
|
||||
|
||||
@implementer(IProcess)
|
||||
class Process(object):
|
||||
|
||||
implements(IProcess)
|
||||
|
||||
def __init__(self):
|
||||
self._startActivity = Activity()
|
||||
|
||||
|
|
|
@ -1,37 +1,17 @@
|
|||
#
|
||||
# Copyright (c) 2006 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
|
||||
#
|
||||
# cybertools.process.execution
|
||||
|
||||
"""
|
||||
Execution of a process.
|
||||
|
||||
$Id$
|
||||
""" Execution of a process.
|
||||
"""
|
||||
|
||||
from zope.interface import implements
|
||||
from zope.interface import implementer
|
||||
from zope.component import adapts
|
||||
from cybertools.process.interfaces import IActivity, IExecution
|
||||
from cybertools.process.interfaces import IWorkItem, IActionHandler
|
||||
|
||||
|
||||
@implementer(IExecution)
|
||||
class Execution(object):
|
||||
|
||||
implements(IExecution)
|
||||
|
||||
def __init__(self, parent=None):
|
||||
self._currentActivity = None
|
||||
self._workItem = None
|
||||
|
@ -65,10 +45,9 @@ class Execution(object):
|
|||
successor.execute(execution)
|
||||
|
||||
|
||||
@implementer(IWorkItem)
|
||||
class WorkItem(object):
|
||||
|
||||
implements(IWorkItem)
|
||||
|
||||
def __init__(self, execution):
|
||||
self._execution = execution
|
||||
self._activity = execution.currentActivity
|
||||
|
@ -88,11 +67,11 @@ class WorkItem(object):
|
|||
self.execution.trigger()
|
||||
|
||||
|
||||
@implementer(IActionHandler)
|
||||
class WorkActionHandler(object):
|
||||
""" A simple action handler that creates a work item.
|
||||
"""
|
||||
|
||||
implements(IActionHandler)
|
||||
adapts(IActivity)
|
||||
|
||||
def __init__(self, context):
|
||||
|
|
Loading…
Add table
Reference in a new issue