process: Python3 fixes

This commit is contained in:
Helmut Merz 2024-09-23 11:14:21 +02:00
parent 8037ac38be
commit f9a3326ec7
3 changed files with 14 additions and 58 deletions

View file

@ -1,8 +1,6 @@
Business Process Management Business Process Management
=========================== ===========================
($Id$)
We start with the definition of a simple process: We start with the definition of a simple process:
startActivity --> n01 --> endActivity startActivity --> n01 --> endActivity
@ -28,15 +26,15 @@ process' end activity:
So let's now associate an action handler with the process' activitys: So let's now associate an action handler with the process' activitys:
>>> from zope.component import provideAdapter, adapts >>> from zope.component import provideAdapter, adapts
>>> from zope.interface import implements >>> from zope.interface import implementer
>>> from cybertools.process.interfaces import IActivity, IActionHandler >>> from cybertools.process.interfaces import IActivity, IActionHandler
>>> class DummyHandler(object): >>> class DummyHandler(object):
... implements(IActionHandler)
... adapts(IActivity) ... adapts(IActivity)
... def __init__(self, context): pass ... def __init__(self, context): pass
... def handle(self, execution): ... def handle(self, execution):
... print 'working.' ... print('working.')
>>> DummyHandler = implementer(IActionHandler)(DummyHandler)
>>> provideAdapter(DummyHandler) >>> provideAdapter(DummyHandler)
>>> execution = process.execute() >>> execution = process.execute()

View file

@ -1,38 +1,18 @@
# # cybertools.process.definition
# 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
#
""" """ Process definitions.
Process definitions.
$Id$
""" """
from zope import component 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 IActivity, IProcess
from cybertools.process.interfaces import IActionHandler from cybertools.process.interfaces import IActionHandler
from cybertools.process.execution import Execution from cybertools.process.execution import Execution
@implementer(IActivity)
class Activity(object): class Activity(object):
implements(IActivity)
def __init__(self, name=u'', title=u'', handlerName=''): def __init__(self, name=u'', title=u'', handlerName=''):
self._successors = set() self._successors = set()
self._handlerName = handlerName self._handlerName = handlerName
@ -61,10 +41,9 @@ class Activity(object):
return execution return execution
@implementer(IProcess)
class Process(object): class Process(object):
implements(IProcess)
def __init__(self): def __init__(self):
self._startActivity = Activity() self._startActivity = Activity()

View file

@ -1,37 +1,17 @@
# # cybertools.process.execution
# 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
#
""" """ Execution of a process.
Execution of a process.
$Id$
""" """
from zope.interface import implements from zope.interface import implementer
from zope.component import adapts from zope.component import adapts
from cybertools.process.interfaces import IActivity, IExecution from cybertools.process.interfaces import IActivity, IExecution
from cybertools.process.interfaces import IWorkItem, IActionHandler from cybertools.process.interfaces import IWorkItem, IActionHandler
@implementer(IExecution)
class Execution(object): class Execution(object):
implements(IExecution)
def __init__(self, parent=None): def __init__(self, parent=None):
self._currentActivity = None self._currentActivity = None
self._workItem = None self._workItem = None
@ -65,10 +45,9 @@ class Execution(object):
successor.execute(execution) successor.execute(execution)
@implementer(IWorkItem)
class WorkItem(object): class WorkItem(object):
implements(IWorkItem)
def __init__(self, execution): def __init__(self, execution):
self._execution = execution self._execution = execution
self._activity = execution.currentActivity self._activity = execution.currentActivity
@ -88,11 +67,11 @@ class WorkItem(object):
self.execution.trigger() self.execution.trigger()
@implementer(IActionHandler)
class WorkActionHandler(object): class WorkActionHandler(object):
""" A simple action handler that creates a work item. """ A simple action handler that creates a work item.
""" """
implements(IActionHandler)
adapts(IActivity) adapts(IActivity)
def __init__(self, context): def __init__(self, context):