[Zope3-checkins] SVN: Zope3/branches/jim-wf/src/zope/wfmc/process.py Fix WorkflowData.get() and refactore the access on the workflowRelevantData using the get() instead of the low level getattr() + trailing whitespaces removals

Julien Anguenot ja at nuxeo.com
Mon Mar 14 13:12:35 EST 2005


Log message for revision 29463:
  Fix WorkflowData.get() and refactore the access on the workflowRelevantData using the get() instead of the low level getattr() +  trailing whitespaces removals

Changed:
  U   Zope3/branches/jim-wf/src/zope/wfmc/process.py

-=-
Modified: Zope3/branches/jim-wf/src/zope/wfmc/process.py
===================================================================
--- Zope3/branches/jim-wf/src/zope/wfmc/process.py	2005-03-14 14:27:59 UTC (rev 29462)
+++ Zope3/branches/jim-wf/src/zope/wfmc/process.py	2005-03-14 18:12:34 UTC (rev 29463)
@@ -72,7 +72,7 @@
     def _start(self):
         # Compute activity incoming and outgoing transitions
         # Return an initial transition
-        
+
         activities = self.activities
 
         # Reinitialize activity transitions
@@ -104,9 +104,9 @@
             else:
                 raise interfaces.InvalidProcessDefinition(
                     "No start activities")
-                
+
         return TransitionDefinition(None, start[0][0])
-        
+
     _start = zope.cachedescriptors.property.Lazy(_start)
 
     def __call__(self, context=None):
@@ -141,7 +141,7 @@
         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):
@@ -159,7 +159,7 @@
         self.to = to
         self.condition = condition
 
-        
+
 class Process(persistent.Persistent):
 
     interface.implements(interfaces.IProcess)
@@ -204,17 +204,15 @@
             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
@@ -255,7 +253,7 @@
         return self.__dict__[name]
 
     def get(self, name):
-        return self.dict.get(name)
+        return self.__dict__.get(name)
 
 class ProcessStarted:
     interface.implements(interfaces.IProcessStarted)
@@ -274,8 +272,8 @@
 
     def __repr__(self):
         return "ProcessFinished(%r)" % self.process
-        
 
+
 class Activity(persistent.Persistent):
 
     interface.implements(interfaces.IActivity)
@@ -309,7 +307,7 @@
                 i += 1
                 workitem.id = i
                 workitems[i] = workitem, application, formal, actual
-        
+
         self.workitems = workitems
 
     def definition(self):
@@ -334,14 +332,14 @@
                 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
@@ -362,7 +360,7 @@
 
         zope.event.notify(WorkItemFinished(
             work_item, app, actual, results))
-        
+
         if not self.workitems:
             self.finish()
 
@@ -446,7 +444,7 @@
 class Application:
 
     interface.implements(interfaces.IApplicationDefinition)
-    
+
     def __init__(self, *parameters):
         self.parameters = parameters
 



More information about the Zope3-Checkins mailing list