[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful - instance.py:1.6

Steve Alexander steve@cat-box.net
Fri, 6 Jun 2003 12:34:54 -0400


Update of /cvs-repository/Zope3/src/zope/app/workflow/stateful
In directory cvs.zope.org:/tmp/cvs-serv5043/src/zope/app/workflow/stateful

Modified Files:
	instance.py 
Log Message:
Removed use of ContextAware mixin class.


=== Zope3/src/zope/app/workflow/stateful/instance.py 1.5 => 1.6 ===
--- Zope3/src/zope/app/workflow/stateful/instance.py:1.5	Tue Jun  3 18:46:23 2003
+++ Zope3/src/zope/app/workflow/stateful/instance.py	Fri Jun  6 12:34:53 2003
@@ -20,7 +20,7 @@
 from types import StringTypes
 from persistence import Persistent
 from zope.schema import getFields
-from zope.interface import directlyProvides
+from zope.interface import directlyProvides, implements
 
 from zope.exceptions import Unauthorized
 
@@ -46,8 +46,7 @@
 from zope.app.workflow.instance import ProcessInstance
 
 
-
-class RelevantData(ContextAware):
+class RelevantData:
     pass
 
 # XXX Example of how Changes to Workflow Relevant Data would send out Events
@@ -96,17 +95,15 @@
     """Stateful Workflow ProcessInstance.
     """
 
-    __implements__ = IStatefulProcessInstance
+    implements(IStatefulProcessInstance)
 
 
     ############################################################
     # Implementation methods for interface
     # zope.app.interfaces.workflow.IStatefulProcessInstance
 
-
-
     data = property(lambda self: ContextWrapper(self._data, self))
-    
+
     # XXX this is not entirely tested nor finished
     #def _getData(self):
     #    """getter for Workflow Relevant Data."""
@@ -132,7 +129,6 @@
     #
     #data = property(lambda self: ContextWrapper(self._getData(), self))
 
-    
     def initialize(self):
         pd = self._getProcessDefinition()
         clean_pd = removeAllProxies(pd)
@@ -150,11 +146,10 @@
         else:
             self._data = None
         # setup permission on data
-        
+
         # check for Automatic Transitions
         self._checkAndFireAuto(clean_pd)
     initialize = ContextMethod(initialize)
-        
 
     def getOutgoingTransitions(self):
         pd = self._getProcessDefinition()
@@ -162,7 +157,6 @@
         return self._outgoingTransitions(clean_pd)
     getOutgoingTransitions = ContextMethod(getOutgoingTransitions)
 
-
     def fireTransition(self, id):
         pd = self._getProcessDefinition()
         clean_pd = removeAllProxies(pd)
@@ -175,7 +169,7 @@
         # send StatusChangingWorkflowEvent
         #print "send StatusChangingWorkflowEvent(old:%s, new:%s) here" \
         #      % (self._status, trans.destinationState)
-        
+
         # change status
         self._status = trans.destinationState
 
@@ -190,7 +184,7 @@
 
     #
     ############################################################
-    
+
     # XXX expose this method in the interface (without _) ???
     def _getProcessDefinition(self):
         """Get the ProcessDefinition object from WorkflowService.
@@ -199,8 +193,6 @@
         return svc.getProcessDefinition(self.processDefinitionName)
     _getProcessDefinition = ContextMethod(_getProcessDefinition)
 
-
-
     # XXX this is not entirely tested
     def _getContext(self):
         ctx = {}
@@ -212,7 +204,7 @@
         # how can we know if this ProcessInstance is annotated
         # to a Content-Object and provide secure ***READONLY***
         # Access to it for evaluating Transition Conditions ???
-        
+
         #content = getWrapperContainer(self)
 
         # XXX How can i make shure that nobody modifies content
@@ -229,9 +221,8 @@
         #    content = Proxy(content, checker)
 
         #ctx['content'] = content
-        
-        return ctx
 
+        return ctx
     _getContext = ContextMethod(_getContext)
 
 
@@ -239,7 +230,6 @@
         ctx['state_change'] = StateChangeInfo(transition)
         return ctx
 
-    
     def _evaluateCondition(self, transition, contexts):
         """Evaluate a condition in context of relevant-data.
         """
@@ -248,7 +238,6 @@
         expr = Engine.compile(transition.condition)
         return expr(Engine.getContext( contexts=contexts ))
 
-
     def _evaluateScript(self, transition, contexts):
         script = transition.script
         if not script:
@@ -259,7 +248,6 @@
         return script(contexts)
     _evaluateScript = ContextMethod(_evaluateScript)
 
-
     def _buildRelevantData(self, schema):
         """Create a new data object and initialize with Schema defaults.
         """
@@ -271,12 +259,11 @@
                 setattr(data, name, field.default)
         return data
 
-
     def _outgoingTransitions(self, clean_pd):
         sm = getSecurityManager()
         ret = []
         contexts = self._getContext()
-        
+
         for name, trans in clean_pd.transitions.items():
             if self.status == trans.sourceState:
                 # check permissions
@@ -297,7 +284,7 @@
                         include = 0
                     if not include:
                         continue
-                    
+
                 if trans.script is not None:
                     try:
                         include = self._evaluateScript(trans, ctx)
@@ -305,12 +292,11 @@
                         include = 0
                     if not include:
                         continue
-                    
+
                 # append transition name
                 ret.append(name)
         return ret
     _outgoingTransitions = ContextMethod(_outgoingTransitions)
-        
 
     def _checkAndFireAuto(self, clean_pd):
         outgoing_transitions = self.getOutgoingTransitions()
@@ -321,4 +307,3 @@
                 self.fireTransition(name)
                 return
     _checkAndFireAuto = ContextMethod(_checkAndFireAuto)
-