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

Commit

Permalink
Fix WorkflowData.get() and refactore the access on the workflowReleva…
Browse files Browse the repository at this point in the history
…ntData using the get() instead of the low level getattr() + trailing whitespaces removals
  • Loading branch information
anguenot committed Mar 14, 2005
1 parent c2a0195 commit a216204
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions process.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def defineParameters(self, *parameters):
def _start(self):
# Compute activity incoming and outgoing transitions
# Return an initial transition

activities = self.activities

# Reinitialize activity transitions
Expand Down Expand Up @@ -104,9 +104,9 @@ def _start(self):
else:
raise interfaces.InvalidProcessDefinition(
"No start activities")

return TransitionDefinition(None, start[0][0])

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

def __call__(self, context=None):
Expand Down Expand Up @@ -141,7 +141,7 @@ def addApplication(self, application, actual=()):
formal = self.process.applications[application].parameters
if len(formal) != len(actual):
raise TypeError("Wrong number of parameters")

self.applications += ((application, formal, tuple(actual)), )

def definePerformer(self, performer):
Expand All @@ -159,7 +159,7 @@ def __init__(self, from_, to, condition=always_true):
self.to = to
self.condition = condition


class Process(persistent.Persistent):

interface.implements(interfaces.IProcess)
Expand Down Expand Up @@ -204,17 +204,15 @@ def _finish(self):
for parameter in self.definition.parameters:
if parameter.output:
args.append(
getattr(self.workflowRelevantData,
parameter.__name__))
self.workflowRelevantData.get(parameter.__name__))
self.context.processFinished(self, *args)

zope.event.notify(ProcessFinished(self))



def transition(self, activity, transitions):
if transitions:
definition = self.definition

for transition in transitions:
activity_definition = definition.activities[transition.to]
next = None
Expand Down Expand Up @@ -255,7 +253,7 @@ def __getitem__(self, name):
return self.__dict__[name]

def get(self, name):
return self.dict.get(name)
return self.__dict__.get(name)

class ProcessStarted:
interface.implements(interfaces.IProcessStarted)
Expand All @@ -274,7 +272,7 @@ def __init__(self, process):

def __repr__(self):
return "ProcessFinished(%r)" % self.process


class Activity(persistent.Persistent):

Expand Down Expand Up @@ -309,7 +307,7 @@ def __init__(self, process, definition):
i += 1
workitem.id = i
workitems[i] = workitem, application, formal, actual

self.workitems = workitems

def definition(self):
Expand All @@ -334,14 +332,14 @@ def start(self, transition):
return # not enough incoming yet

zope.event.notify(ActivityStarted(self))

if self.workitems:
for workitem, app, formal, actual in self.workitems.values():
args = []
for parameter, name in zip(formal, actual):
if parameter.input:
args.append(
getattr(self.process.workflowRelevantData, name))
self.process.workflowRelevantData.get(name))
workitem.start(*args)
else:
# Since we don't have any work items, we're done
Expand All @@ -362,7 +360,7 @@ def workItemFinished(self, work_item, *results):

zope.event.notify(WorkItemFinished(
work_item, app, actual, results))

if not self.workitems:
self.finish()

Expand Down Expand Up @@ -446,7 +444,7 @@ class InputOutputParameter(InputParameter, OutputParameter):
class Application:

interface.implements(interfaces.IApplicationDefinition)

def __init__(self, *parameters):
self.parameters = parameters

Expand Down

0 comments on commit a216204

Please sign in to comment.