[Zope3-checkins] CVS: Zope3/src/zope/app/workflow -
definition.py:1.3.24.4 instance.py:1.7.6.4
Jim Fulton
jim at zope.com
Mon Sep 15 14:13:11 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/workflow
In directory cvs.zope.org:/tmp/cvs-serv15511/src/zope/app/workflow
Modified Files:
Tag: parentgeddon-branch
definition.py instance.py
Log Message:
Got lots of tests to pass.
Added a setitem helper function to be used to help satisfy container
contracts.
=== Zope3/src/zope/app/workflow/definition.py 1.3.24.3 => 1.3.24.4 ===
--- Zope3/src/zope/app/workflow/definition.py:1.3.24.3 Fri Sep 12 15:15:39 2003
+++ Zope3/src/zope/app/workflow/definition.py Mon Sep 15 14:12:41 2003
@@ -23,7 +23,7 @@
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
+from zope.app.container.contained import Contained, setitem, uncontained
class ProcessDefinition(Persistent, Contained):
@@ -43,10 +43,6 @@
#
############################################################
-
-
-
-
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,33 +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 __setitem__(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 self.__parent__
=== Zope3/src/zope/app/workflow/instance.py 1.7.6.3 => 1.7.6.4 ===
--- Zope3/src/zope/app/workflow/instance.py:1.7.6.3 Fri Sep 12 15:15:39 2003
+++ Zope3/src/zope/app/workflow/instance.py Mon Sep 15 14:12:41 2003
@@ -28,7 +28,7 @@
from zope.interface import implements
from zope.component import getAdapter
-from zope.app.container.contained import Contained
+from zope.app.container.contained import Contained, setitem, uncontained
# XXX should an Instance be persistent by default ???
class ProcessInstance(Contained):
@@ -109,24 +109,16 @@
def __setitem__(self, key, object):
"See IProcessInstanceContainer"
-
- if not isinstance(key, StringTypes):
- raise TypeError("Item name is not a string.")
-
- container = self.wfdata
- object = removeAllProxies(object)
- container[key] = object
- # publish event ??
- return key
+ setitem(self, self.wfdata.__setitem__, key, object)
def __delitem__(self, key):
"See IZopeWriteContainer"
container = self.wfdata
# publish event ?
+ uncontained(container[key], self, key)
del container[key]
- return key
def __iter__(self):
'''See interface IReadContainer'''
- return iter(self.context)
+ return iter(self.wfdata)
More information about the Zope3-Checkins
mailing list