Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
Preparations for persistent WFMC,
Browse files Browse the repository at this point in the history
as discussed at the SwissSprint
  • Loading branch information
Adam Groszer committed Apr 28, 2006
1 parent 6abdd6a commit bfd0611
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
38 changes: 20 additions & 18 deletions process.py
Expand Up @@ -26,9 +26,28 @@

from zope.wfmc import interfaces

def always_true(data):
return True

class TransitionDefinition(object):

interface.implements(interfaces.ITransitionDefinition)

def __init__(self, from_, to, condition=always_true, id=None):
self.id = id
self.from_ = from_
self.to = to
self.condition = condition

def __repr__(self):
return "TransitionDefinition(from=%r, to=%r)" %(self.from_, self.to)


class ProcessDefinition(object):

interface.implements(interfaces.IProcessDefinition)

TransitionDefinitionFactory = TransitionDefinition

def __init__(self, id, integration=None):
self.id = id
Expand Down Expand Up @@ -99,7 +118,7 @@ def _start(self):
raise interfaces.InvalidProcessDefinition(
"No start activities")

return TransitionDefinition(None, start[0][0])
return self.TransitionDefinitionFactory(None, start[0][0])

_start = zope.cachedescriptors.property.Lazy(_start)

Expand Down Expand Up @@ -167,23 +186,6 @@ def __repr__(self):
return "<ActivityDefinition %r>" %self.__name__


def always_true(data):
return True

class TransitionDefinition(object):

interface.implements(interfaces.ITransitionDefinition)

def __init__(self, from_, to, condition=always_true, id=None):
self.id = id
self.from_ = from_
self.to = to
self.condition = condition

def __repr__(self):
return "TransitionDefinition(from=%r, to=%r)" %(self.from_, self.to)


class Process(persistent.Persistent):

interface.implements(interfaces.IProcess)
Expand Down
18 changes: 12 additions & 6 deletions xpdl.py
Expand Up @@ -65,6 +65,12 @@ class XPDLHandler(xml.sax.handler.ContentHandler):
start_handlers = {}
end_handlers = {}
text = u''

ProcessDefinitionFactory = zope.wfmc.process.ProcessDefinition
ParticipantFactory = zope.wfmc.process.Participant
ApplicationFactory = zope.wfmc.process.Application
ActivityDefinitionFactory = zope.wfmc.process.ActivityDefinition
TransitionDefinitionFactory = zope.wfmc.process.TransitionDefinition

def __init__(self, package):
self.package = package
Expand Down Expand Up @@ -120,7 +126,7 @@ def Package(self, attrs):

def WorkflowProcess(self, attrs):
id = attrs[(None, 'Id')]
process = zope.wfmc.process.ProcessDefinition(id)
process = self.ProcessDefinitionFactory(id)
process.__name__ = attrs.get((None, 'Name'))

# Copy package data:
Expand All @@ -147,14 +153,14 @@ def FormalParameter(self, attrs):
def Participant(self, attrs):
id = attrs[(None, 'Id')]
name = attrs.get((None, 'Name'))
participant = zope.wfmc.process.Participant(name)
participant = self.ParticipantFactory(name)
self.stack[-1].defineParticipants(**{str(id): participant})
start_handlers[(xpdlns, 'Participant')] = Participant

def Application(self, attrs):
id = attrs[(None, 'Id')]
name = attrs.get((None, 'Name'))
app = zope.wfmc.process.Application()
app = self.ApplicationFactory()
app.id = id
if name:
app.__name__ = name
Expand All @@ -180,7 +186,7 @@ def ActivitySet(self, attrs):
def Activity(self, attrs):
id = attrs[(None, 'Id')]
name = attrs.get((None, 'Name'))
activity = zope.wfmc.process.ActivityDefinition(name)
activity = self.ActivityDefinitionFactory(name)
activity.id = id
self.stack[-1].defineActivities(**{str(id): activity})
return activity
Expand Down Expand Up @@ -228,7 +234,7 @@ def Transition(self, attrs):
name = attrs.get((None, 'Name'))
from_ = attrs.get((None, 'From'))
to = attrs.get((None, 'To'))
transition = zope.wfmc.process.TransitionDefinition(from_, to)
transition = self.TransitionDefinitionFactory(from_, to)
transition.id = id
return transition
start_handlers[(xpdlns, 'Transition')] = Transition
Expand All @@ -239,7 +245,7 @@ def transition(self, transition):

def condition(self, ignored):
assert isinstance(self.stack[-1],
zope.wfmc.process.TransitionDefinition)
self.TransitionDefinitionFactory)

text = self.text
self.stack[-1].condition = TextCondition("(%s)" % text)
Expand Down

0 comments on commit bfd0611

Please sign in to comment.