[Zope3-checkins] CVS: Zope3/src/zope/app/workflow - instance.py:1.8
Jim Fulton
jim at zope.com
Sun Sep 21 13:33:53 EDT 2003
Update of /cvs-repository/Zope3/src/zope/app/workflow
In directory cvs.zope.org:/tmp/cvs-serv15655/src/zope/app/workflow
Modified Files:
instance.py
Log Message:
Changed to use __setitem__ rather than setObject
No-longer use context wrappers.
=== Zope3/src/zope/app/workflow/instance.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/workflow/instance.py:1.7 Fri Aug 15 20:44:31 2003
+++ Zope3/src/zope/app/workflow/instance.py Sun Sep 21 13:33:53 2003
@@ -19,7 +19,6 @@
from types import StringTypes
from persistence.dict import PersistentDict
-from zope.app.context import ContextWrapper
from zope.proxy import removeAllProxies
from zope.app.interfaces.annotation import IAnnotatable, IAnnotations
@@ -29,8 +28,10 @@
from zope.interface import implements
from zope.component import getAdapter
+from zope.app.container.contained import Contained, setitem, uncontained
+
# XXX should an Instance be persistent by default ???
-class ProcessInstance:
+class ProcessInstance(Contained):
__doc__ = IProcessInstance.__doc__
@@ -76,13 +77,13 @@
def __getitem__(self, key):
"See IProcessInstanceContainer"
value = self.wfdata[key]
- return ContextWrapper(value, self.context, name=key)
+ return value
def get(self, key, default=None):
"See IProcessInstanceContainer"
value = self.wfdata.get(key, _marker)
if value is not _marker:
- return ContextWrapper(value, self.context, name=key)
+ return value
else:
return default
@@ -92,11 +93,7 @@
def values(self):
"See IProcessInstanceContainer"
- container = self.wfdata
- result = []
- for key, value in container.items():
- result.append(ContextWrapper(value, self.context, name=key))
- return result
+ return self.wfdata.values()
def keys(self):
"See IProcessInstanceContainer"
@@ -108,32 +105,20 @@
def items(self):
"See IProcessInstanceContainer"
- container = self.wfdata
- result = []
- for key, value in container.items():
- result.append((key, ContextWrapper(value, self.context, name=key)))
- return result
+ return self.wfdata.items()
- def setObject(self, key, object):
+ 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