[Zope3-checkins] CVS: Zope3/src/zope/app/workflow - definition.py:1.4

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


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

Modified Files:
	definition.py 
Log Message:
No-longer use context wrappers.


=== Zope3/src/zope/app/workflow/definition.py 1.3 => 1.4 ===
--- Zope3/src/zope/app/workflow/definition.py:1.3	Fri Jun  6 12:34:53 2003
+++ Zope3/src/zope/app/workflow/definition.py	Sun Sep 21 13:33:52 2003
@@ -20,12 +20,12 @@
 from types import StringTypes
 from persistence import Persistent
 from persistence.dict import PersistentDict
-from zope.context import ContextMethod, getWrapperContainer
-from zope.app.interfaces.workflow \
-     import IProcessDefinition, IProcessDefinitionElementContainer
+from zope.app.interfaces.workflow import IProcessDefinitionElementContainer
+from zope.app.interfaces.workflow import IProcessDefinition
 from zope.interface import implements
+from zope.app.container.contained import Contained, setitem, uncontained
 
-class ProcessDefinition(Persistent):
+class ProcessDefinition(Persistent, Contained):
 
     __doc__ = IProcessDefinition.__doc__
 
@@ -43,11 +43,7 @@
     #
     ############################################################
 
-
-
-
-
-class ProcessDefinitionElementContainer(Persistent):
+class ProcessDefinitionElementContainer(Persistent, Contained):
     """ See IProcessDefinitionElementContainer.
     """
 
@@ -64,13 +60,13 @@
     def __iter__(self):
         return iter(self.__data.keys())
 
-    def __getitem__(self, key):
+    def __getitem__(self, name):
         '''See interface IProcessDefinitionElementContainer'''
-        return self.__data[key]
+        return self.__data[name]
 
-    def get(self, key, default=None):
+    def get(self, name, default=None):
         '''See interface IProcessDefinitionElementContainer'''
-        return self.__data.get(key, default)
+        return self.__data.get(name, default)
 
     def values(self):
         '''See interface IProcessDefinitionElementContainer'''
@@ -84,34 +80,20 @@
         '''See interface IProcessDefinitionElementContainer'''
         return self.__data.items()
 
-    def __contains__(self, key):
+    def __contains__(self, name):
         '''See interface IProcessDefinitionElementContainer'''
-        return self.__data.has_key(key)
+        return name in self.__data
 
     has_key = __contains__
 
-    def setObject(self, key, object):
+    def __setitem__(self, name, object):
         '''See interface IProcessDefinitionElementContainer'''
-        bad = False
-        if isinstance(key, StringTypes):
-            try:
-                unicode(key)
-            except UnicodeError:
-                bad = True
-        else:
-            bad = True
-        if bad:
-            raise TypeError("'%s' is invalid, the key must be an "
-                            "ascii or unicode string" % key)
-        if len(key) == 0:
-            raise ValueError("The key cannot be an empty string")
-        self.__data[key] = object
-        return key
+        setitem(self, self.__data.__setitem__, name, object)
 
-    def __delitem__(self, key):
+    def __delitem__(self, name):
         '''See interface IProcessDefinitionElementContainer'''
-        del self.__data[key]
+        uncontained(self.__data[name], self, name)
+        del self.__data[name]
 
     def getProcessDefinition(self):
-        return getWrapperContainer(self)
-    getProcessDefinition = ContextMethod(getProcessDefinition)
+        return self.__parent__




More information about the Zope3-Checkins mailing list