[Checkins] SVN: zope.container/trunk/ Merge "movedaddedremoved" branch:

Chris McDonough chrism at plope.com
Sun May 17 12:37:07 EDT 2009


Log message for revision 100036:
  Merge "movedaddedremoved" branch:
  
  - Rid ourselves of ``IObjectMovedEvent``, ``IObjectAddedEvent``,
    ``IObjectRemovedEvent`` interfaces and ``ObjectMovedEvent``,
    ``ObjectAddedEvent`` and ``ObjectRemovedEvent`` classes.  All of
    these were moved to ``zope.lifecycleevent``. Depend on
    ``zope.lifecycleevent``>=3.5.2.
  
  
  

Changed:
  U   zope.container/trunk/CHANGES.txt
  U   zope.container/trunk/setup.py
  U   zope.container/trunk/src/zope/container/configure.zcml
  U   zope.container/trunk/src/zope/container/contained.py
  U   zope.container/trunk/src/zope/container/interfaces.py
  U   zope.container/trunk/src/zope/container/tests/test_dependency.py
  U   zope.container/trunk/src/zope/container/tests/test_ordered.py

-=-
Modified: zope.container/trunk/CHANGES.txt
===================================================================
--- zope.container/trunk/CHANGES.txt	2009-05-17 16:30:20 UTC (rev 100035)
+++ zope.container/trunk/CHANGES.txt	2009-05-17 16:37:07 UTC (rev 100036)
@@ -4,6 +4,13 @@
 
 3.8.2 (unreleased)
 ------------------
+
+- Rid ourselves of ``IObjectMovedEvent``, ``IObjectAddedEvent``,
+  ``IObjectRemovedEvent`` interfaces and ``ObjectMovedEvent``,
+  ``ObjectAddedEvent`` and ``ObjectRemovedEvent`` classes.  All of
+  these were moved to ``zope.lifecycleevent``. Depend on
+  ``zope.lifecycleevent``>=3.5.2.
+
 - Fix a bug in OrderedContainer where trying to set the value for a
   key that already exists (duplication error) would actually delete the
   key from the order, leaving a dangling reference.

Modified: zope.container/trunk/setup.py
===================================================================
--- zope.container/trunk/setup.py	2009-05-17 16:30:20 UTC (rev 100035)
+++ zope.container/trunk/setup.py	2009-05-17 16:37:07 UTC (rev 100036)
@@ -72,7 +72,7 @@
                         'zope.event',
                         'zope.location',
                         'zope.security',
-                        'zope.lifecycleevent',
+                        'zope.lifecycleevent>=3.5.2',
                         'zope.i18nmessageid',
                         'zope.filerepresentation',
                         'zope.size',

Modified: zope.container/trunk/src/zope/container/configure.zcml
===================================================================
--- zope.container/trunk/src/zope/container/configure.zcml	2009-05-17 16:30:20 UTC (rev 100035)
+++ zope.container/trunk/src/zope/container/configure.zcml	2009-05-17 16:37:07 UTC (rev 100036)
@@ -59,13 +59,13 @@
   <subscriber
       zcml:condition="installed zope.app.dependable"
       handler=".dependency.CheckDependency"
-      for="zope.container.interfaces.IObjectRemovedEvent"
+      for="zope.lifecycleevent.interfaces.IObjectRemovedEvent"
       trusted="y"
       />
 
   <subscriber
       for="zope.location.interfaces.ILocation
-           zope.container.interfaces.IObjectMovedEvent"
+           zope.lifecycleevent.interfaces.IObjectMovedEvent"
       handler=".contained.dispatchToSublocations"
       >
       Handler dispatches moved events to sublocations of the original object.

Modified: zope.container/trunk/src/zope/container/contained.py
===================================================================
--- zope.container/trunk/src/zope/container/contained.py	2009-05-17 16:30:20 UTC (rev 100035)
+++ zope.container/trunk/src/zope/container/contained.py	2009-05-17 16:37:07 UTC (rev 100036)
@@ -23,7 +23,6 @@
 from zope.interface.declarations import getObjectSpecification
 from zope.interface.declarations import ObjectSpecification
 from zope.event import notify
-from zope.component.interfaces import ObjectEvent
 from zope.location.interfaces import ILocation, ISublocations
 from zope.security.checker import selectChecker, CombinedChecker
 from zope.lifecycleevent import ObjectModifiedEvent
@@ -32,12 +31,14 @@
 from zope.container.interfaces import IContained
 from zope.container.interfaces import INameChooser
 from zope.container.interfaces import IReservedNames, NameReserved
-from zope.container.interfaces import IObjectAddedEvent
-from zope.container.interfaces import IObjectMovedEvent
-from zope.container.interfaces import IObjectRemovedEvent
 from zope.container.interfaces import IContainerModifiedEvent
 from zope.container._zope_container_contained import ContainedProxyBase
 from zope.container._zope_container_contained import getProxiedObject
+
+from zope.lifecycleevent import ObjectMovedEvent
+from zope.lifecycleevent import ObjectAddedEvent
+from zope.lifecycleevent import ObjectRemovedEvent
+
 from zope.broken.interfaces import IBroken
 
 class Contained(object):
@@ -47,42 +48,6 @@
 
     __parent__ = __name__ = None
 
-class ObjectMovedEvent(ObjectEvent):
-    """An object has been moved"""
-
-    zope.interface.implements(IObjectMovedEvent)
-
-    def __init__(self, object, oldParent, oldName, newParent, newName):
-        ObjectEvent.__init__(self, object)
-        self.oldParent = oldParent
-        self.oldName = oldName
-        self.newParent = newParent
-        self.newName = newName
-
-class ObjectAddedEvent(ObjectMovedEvent):
-    """An object has been added to a container"""
-
-    zope.interface.implements(IObjectAddedEvent)
-
-    def __init__(self, object, newParent=None, newName=None):
-        if newParent is None:
-            newParent = object.__parent__
-        if newName is None:
-            newName = object.__name__
-        ObjectMovedEvent.__init__(self, object, None, None, newParent, newName)
-
-class ObjectRemovedEvent(ObjectMovedEvent):
-    """An object has been removed from a container"""
-
-    zope.interface.implements(IObjectRemovedEvent)
-
-    def __init__(self, object, oldParent=None, oldName=None):
-        if oldParent is None:
-            oldParent = object.__parent__
-        if oldName is None:
-            oldName = object.__name__
-        ObjectMovedEvent.__init__(self, object, oldParent, oldName, None, None)
-
 class ContainerModifiedEvent(ObjectModifiedEvent):
     """The container has been modified."""
 
@@ -147,6 +112,7 @@
        Now we'll register it:
 
          >>> from zope import component
+         >>> from zope.lifecycleevent.interfaces import IObjectMovedEvent
          >>> component.provideHandler(handler, [None, IObjectMovedEvent])
 
        We also register our dispatcher:
@@ -380,8 +346,8 @@
     ...     def setMoved(self, event):
     ...         self.moved = event
 
-    >>> from zope.container.interfaces import IObjectAddedEvent
-    >>> from zope.container.interfaces import IObjectMovedEvent
+    >>> from zope.lifecycleevent.interfaces import IObjectAddedEvent
+    >>> from zope.lifecycleevent.interfaces import IObjectMovedEvent
 
     >>> from zope import component
     >>> component.provideHandler(lambda obj, event: obj.setAdded(event),
@@ -600,7 +566,7 @@
 
     >>> from zope.component.eventtesting import getEvents
     >>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent
-    >>> from zope.container.interfaces import IObjectRemovedEvent
+    >>> from zope.lifecycleevent.interfaces import IObjectRemovedEvent
 
     We'll start by creating a container with an item:
 

Modified: zope.container/trunk/src/zope/container/interfaces.py
===================================================================
--- zope.container/trunk/src/zope/container/interfaces.py	2009-05-17 16:30:20 UTC (rev 100035)
+++ zope.container/trunk/src/zope/container/interfaces.py	2009-05-17 16:37:07 UTC (rev 100036)
@@ -17,14 +17,21 @@
 """
 __docformat__ = 'restructuredtext'
 
-from zope.interface import Interface, Attribute, Invalid
+from zope.interface import Interface, Invalid
 from zope.interface.common.mapping import IItemMapping
 from zope.interface.common.mapping import IReadMapping, IEnumerableMapping
-from zope.component.interfaces import IObjectEvent
-from zope.lifecycleevent.interfaces import IObjectModifiedEvent
 from zope.location.interfaces import ILocation
 from zope.schema import Set
 
+from zope.lifecycleevent.interfaces import IObjectModifiedEvent
+
+# the following imports provide backwards compatibility for consumers;
+# do not remove them
+from zope.lifecycleevent.interfaces import IObjectMovedEvent
+from zope.lifecycleevent.interfaces import IObjectAddedEvent
+from zope.lifecycleevent.interfaces import IObjectRemovedEvent
+# /end backwards compatibility imports
+
 from zope.container.i18n import ZopeMessageFactory as _
 
 class DuplicateIDError(KeyError):
@@ -215,18 +222,6 @@
     __doc__ = _("""The name is reserved for this container""")
 
 ##############################################################################
-# Moving Objects
-
-class IObjectMovedEvent(IObjectEvent):
-    """An object has been moved."""
-
-    oldParent = Attribute("The old location parent for the object.")
-    oldName = Attribute("The old location name for the object.")
-    newParent = Attribute("The new location parent for the object.")
-    newName = Attribute("The new location name for the object.")
-
-
-##############################################################################
 # Adding objects
 
 class UnaddableError(ContainerError):
@@ -242,10 +237,6 @@
                 "to %(container)s%(message)s" % self.__dict__)
 
 
-class IObjectAddedEvent(IObjectMovedEvent):
-    """An object has been added to a container."""
-
-
 class INameChooser(Interface):
 
     def checkName(name, object):
@@ -267,14 +258,6 @@
 
 
 ##############################################################################
-# Removing objects
-
-
-class IObjectRemovedEvent(IObjectMovedEvent):
-    """An object has been removed from a container."""
-
-
-##############################################################################
 # Modifying containers
 
 

Modified: zope.container/trunk/src/zope/container/tests/test_dependency.py
===================================================================
--- zope.container/trunk/src/zope/container/tests/test_dependency.py	2009-05-17 16:30:20 UTC (rev 100035)
+++ zope.container/trunk/src/zope/container/tests/test_dependency.py	2009-05-17 16:37:07 UTC (rev 100036)
@@ -19,7 +19,7 @@
 
 from zope.interface import implements
 from zope.app.dependable.interfaces import IDependable, DependencyError
-from zope.container.contained import ObjectRemovedEvent
+from zope.lifecycleevent import ObjectRemovedEvent
 from zope.container.dependency import CheckDependency
 from zope.traversing.interfaces import IPhysicallyLocatable
 

Modified: zope.container/trunk/src/zope/container/tests/test_ordered.py
===================================================================
--- zope.container/trunk/src/zope/container/tests/test_ordered.py	2009-05-17 16:30:20 UTC (rev 100035)
+++ zope.container/trunk/src/zope/container/tests/test_ordered.py	2009-05-17 16:37:07 UTC (rev 100036)
@@ -69,8 +69,9 @@
 
         >>> import zope.component
         >>> from zope.container import interfaces
+        >>> from zope.lifecycleevent.interfaces import IObjectAddedEvent
 
-        >>> @zope.component.adapter(interfaces.IObjectAddedEvent)
+        >>> @zope.component.adapter(IObjectAddedEvent)
         ... def printContainerKeys(event):
         ...     print event.newParent.keys()
 
@@ -97,8 +98,9 @@
 
         >>> import zope.component
         >>> from zope.container import interfaces
+        >>> from zope.lifecycleevent.interfaces import IObjectAddedEvent
 
-        >>> @zope.component.adapter(interfaces.IObjectAddedEvent)
+        >>> @zope.component.adapter(IObjectAddedEvent)
         ... def raiseException(event):
         ...     raise Exception()
 



More information about the Checkins mailing list