[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces - container.py:1.3.2.3

Jim Fulton jim at zope.com
Mon Sep 15 14:13:06 EDT 2003


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

Modified Files:
      Tag: parentgeddon-branch
	container.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/interfaces/container.py 1.3.2.2 => 1.3.2.3 ===
--- Zope3/src/zope/app/interfaces/container.py:1.3.2.2	Fri Sep 12 15:15:29 2003
+++ Zope3/src/zope/app/interfaces/container.py	Mon Sep 15 14:12:36 2003
@@ -49,11 +49,14 @@
 class IWriteContainer(Interface):
     """An interface for the write aspects of a container."""
 
-    def __setitem__(key, object):
-        """Add the given object to the container under the given key.
+    def __setitem__(name, object):
+        """Add the given object to the container under the given name.
+
+        Raises a TypeError if the key is not a unicode or ascii string.
+        Raises a ValueError if key is empty.
 
         The container might choose to add a different object than the
-        one passed to this method.
+        one passed to this method. 
 
         If the object doesn't implement IContained, then one of two
         things must be done:
@@ -64,13 +67,48 @@
         2. Otherwise, a ContainedProxy is created for the object and
            stored.
 
-        The object's __parent__ and __name__ attributes are set.
+        The object's __parent__ and __name__ attributes are set to the
+        container and the given name.
+
+        If the old parent was None, then an IObjectAddedEvent is
+        generated, otherwise, and IObjectMovedEvent is generated.  An
+        IObjectModifiedEvent is generated for the container.  If an
+        add event is generated and the object can be adapted to
+        IAddNotifiable, then the adapter's addNotify method is called
+        with the event.  If the object can be adapted to
+        IMoveNotifiable, then the adapter's moveNotify method is
+        called with the event.
+
+        If the object replaces another object, then the old object is
+        deleted before the new object is added, unless the container
+        vetos the replacement by raising an exception.
+
+        If the object's __parent__ and __name__ were already set to
+        the container and the name, then no events are generated and
+        no hooks.  This allows advanced clients to take over event
+        generation.
+        
         """
 
-    def __delitem__(key):
-        """Delete the keyed object from the container.
+    def __delitem__(name):
+        """Delete the nameed object from the container.
 
         Raises a KeyError if the object is not found.
+
+        If the deleted object's __parent__ and __name__ match the
+        container and given name, then an IObjectRemovedEvent is
+        generated and the attributes are set to None. If the object
+        can be adapted to IMoveNotifiable, then the adapter's
+        moveNotify method is called with the event.
+
+        Unless the object's __parent__ and __name__ attributes were
+        initially None, generate an IObjectModifiedEvent for the
+        container. 
+
+        If the object's __parent__ and __name__ were already set to
+        None, then no events are generated.  This allows advanced
+        clients to take over event generation.
+        
         """
 
 class IItemWriteContainer(IWriteContainer, IItemContainer):




More information about the Zope3-Checkins mailing list