[Zope3-checkins] CVS: Zope3/src/zope/app/workflow/stateful - contentworkflow.py:1.8 definition.py:1.7

Jim Fulton jim at zope.com
Sun Sep 21 13:33:56 EDT 2003


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

Modified Files:
	contentworkflow.py definition.py 
Log Message:
Changed to use __setitem__ rather than setObject

No-longer use context wrappers.


=== Zope3/src/zope/app/workflow/stateful/contentworkflow.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/workflow/stateful/contentworkflow.py:1.7	Tue Jul 29 20:00:25 2003
+++ Zope3/src/zope/app/workflow/stateful/contentworkflow.py	Sun Sep 21 13:33:56 2003
@@ -22,7 +22,6 @@
 from persistence import Persistent
 from persistence.dict import PersistentDict
 from zope.component import getService, queryAdapter
-from zope.context import ContextMethod
 
 from zope.app.interfaces.event import ISubscriber
 from zope.app.interfaces.event import IObjectCreatedEvent
@@ -32,9 +31,10 @@
 from zope.app.interfaces.workflow import IProcessInstanceContainerAdaptable
 from zope.app.interfaces.workflow.stateful import IContentWorkflowsManager
 from zope.interface import implements, providedBy
+from zope.app.container.contained import Contained
 
 
-class ContentWorkflowsManager(Persistent):
+class ContentWorkflowsManager(Persistent, Contained):
 
     implements(IContentWorkflowsManager, ISubscriber)
 
@@ -75,9 +75,8 @@
                 except KeyError:
                     # No registered PD with that name..
                     continue
-                pi_container.setObject(pd_name, pi)
+                pi_container[pd_name] = pi
 
-    notify = ContextMethod(notify)
 
 
     def subscribe(self):
@@ -87,7 +86,6 @@
         channel = self._getChannel(None)
         channel.subscribe(self, IObjectCreatedEvent)
         self.currentlySubscribed = True
-    subscribe = ContextMethod(subscribe)
 
     def unsubscribe(self):
         """See interfaces.workflows.stateful.IContentWorkflowsManager"""
@@ -96,7 +94,6 @@
         channel = self._getChannel(None)
         channel.unsubscribe(self, IObjectCreatedEvent)
         self.currentlySubscribed = False
-    unsubscribe = ContextMethod(unsubscribe)
 
     def isSubscribed(self):
         """See interfaces.workflows.stateful.IContentWorkflowsManager"""
@@ -106,7 +103,6 @@
         if channel is None:
             channel = getService(self, EventSubscription)
         return channel
-    _getChannel = ContextMethod(_getChannel)
 
     def getProcessDefinitionNamesForObject(self, object):
         """See interfaces.workflows.stateful.IContentWorkflowsManager"""


=== Zope3/src/zope/app/workflow/stateful/definition.py 1.6 => 1.7 ===
--- Zope3/src/zope/app/workflow/stateful/definition.py:1.6	Thu Jul 31 11:01:36 2003
+++ Zope3/src/zope/app/workflow/stateful/definition.py	Sun Sep 21 13:33:56 2003
@@ -21,9 +21,7 @@
 from persistence import Persistent
 from persistence.dict import PersistentDict
 
-from zope.app.context import ContextWrapper
-from zope.context import getWrapperContainer
-from zope.context import ContextMethod
+from zope.app.container.contained import Contained
 
 from zope.app.interfaces.container import IReadContainer
 
@@ -36,9 +34,10 @@
 from zope.app.workflow.definition import ProcessDefinitionElementContainer
 from zope.app.workflow.stateful.instance import StatefulProcessInstance
 from zope.interface import implements
+from zope.app.container.contained import Contained
 
 
-class State(Persistent):
+class State(Persistent, Contained):
     """State."""
     implements(IState)
 
@@ -48,7 +47,7 @@
     implements(IStatefulStatesContainer)
 
 
-class Transition(Persistent):
+class Transition(Persistent, Contained):
     """Transition from one state to another."""
 
     implements(ITransition)
@@ -119,8 +118,7 @@
                            "TriggerMode for Transition.")
 
     def getProcessDefinition(self):
-        return getWrapperContainer(self).getProcessDefinition()
-    getProcessDefinition = ContextMethod(getProcessDefinition)
+        return self.__parent__.getProcessDefinition()
 
 
 class TransitionsContainer(ProcessDefinitionElementContainer):
@@ -137,7 +135,7 @@
         super(StatefulProcessDefinition, self).__init__()
         self.__states = StatesContainer()
         initial = State()
-        self.__states.setObject(self.getInitialStateName(), initial)
+        self.__states[self.getInitialStateName()] = initial
         self.__transitions = TransitionsContainer()
         self.__schema = None
         # See workflow.stateful.IStatefulProcessDefinition
@@ -167,12 +165,11 @@
         """See workflow.stateful.IStatefulProcessDefinition"""
         if name in self.states:
             raise KeyError, name
-        self.states.setObject(name, state)
+        self.states[name] = state
 
     def getState(self, name):
         """See workflow.stateful.IStatefulProcessDefinition"""
         return self.states[name]
-    getState = ContextMethod(getState)
 
     def removeState(self, name):
         """See workflow.stateful.IStatefulProcessDefinition"""
@@ -190,12 +187,11 @@
         """See workflow.stateful.IStatefulProcessDefinition"""
         if name in self.transitions:
             raise KeyError, name
-        self.transitions.setObject(name, transition)
+        self.transitions[name] = transition
 
     def getTransition(self, name):
         """See workflow.stateful.IStatefulProcessDefinition"""
         return self.transitions[name]
-    getTransition = ContextMethod(getTransition)
 
     def removeTransition(self, name):
         """See workflow.stateful.IStatefulProcessDefinition"""
@@ -208,9 +204,15 @@
     def createProcessInstance(self, definition_name):
         """See workflow.IProcessDefinition"""
         pi_obj = StatefulProcessInstance(definition_name)
-        ContextWrapper(pi_obj, self).initialize()
+
+        # XXX
+        # Process instances need to have a place, so they can look things
+        # up.  It's not clear to me (Jim) what place they should have.
+        pi_obj.__parent__ = self
+
+
+        pi_obj.initialize()
         return pi_obj
-    createProcessInstance = ContextMethod(createProcessInstance)
 
 
     def __getitem__(self, key):
@@ -222,7 +224,6 @@
 
         return result
 
-    __getitem__ = ContextMethod(__getitem__)
 
     def get(self, key, default=None):
         "See Interface.Common.Mapping.IReadMapping"
@@ -235,7 +236,6 @@
 
         return default
 
-    get = ContextMethod(get)
 
     def __contains__(self, key):
         "See Interface.Common.Mapping.IReadMapping"
@@ -253,12 +253,10 @@
     def values(self):
         """See zope.app.interfaces.container.IReadContainer"""
         return map(self.get, self.keys())
-    values = ContextMethod(values)
 
     def items(self):
         """See zope.app.interfaces.container.IReadContainer"""
         return [(key, self.get(key)) for key in self.keys()]
-    items = ContextMethod(items)
 
     def __len__(self):
         """See zope.app.interfaces.container.IReadContainer"""




More information about the Zope3-Checkins mailing list