[Zope3-checkins] SVN: Zope3/trunk/ Added modified description for sequence-like interfaces.

Dominik Huber dominik.huber at perse.ch
Sat Oct 8 07:34:13 EDT 2005


Log message for revision 38938:
  Added modified description for sequence-like interfaces.

Changed:
  U   Zope3/trunk/doc/CHANGES.txt
  U   Zope3/trunk/src/zope/app/event/interfaces.py
  U   Zope3/trunk/src/zope/app/event/objectevent.py

-=-
Modified: Zope3/trunk/doc/CHANGES.txt
===================================================================
--- Zope3/trunk/doc/CHANGES.txt	2005-10-08 11:31:46 UTC (rev 38937)
+++ Zope3/trunk/doc/CHANGES.txt	2005-10-08 11:34:12 UTC (rev 38938)
@@ -10,6 +10,8 @@
 
     New features
 
+      - Added modified description for sequence-like interfaces.
+
       - Added a test browser. The test browser simulates a real Web browser as
         much as possible as a Python object. This allows us to write
         functional tests the same way the site would be experienced by the

Modified: Zope3/trunk/src/zope/app/event/interfaces.py
===================================================================
--- Zope3/trunk/src/zope/app/event/interfaces.py	2005-10-08 11:31:46 UTC (rev 38937)
+++ Zope3/trunk/src/zope/app/event/interfaces.py	2005-10-08 11:34:12 UTC (rev 38938)
@@ -29,35 +29,50 @@
 
     object = Attribute("The subject of the event.")
 
+
 class IObjectCreatedEvent(IObjectEvent):
     """An object has been created.
 
     The location will usually be ``None`` for this event."""
 
+
 class IObjectCopiedEvent(IObjectCreatedEvent):
     """An object has been copied"""
 
+
 class IObjectModifiedEvent(IObjectEvent):
     """An object has been modified"""
 
+
 class IModificationDescription(Interface) :
     """ Marker interface for descriptions of object modifications.
-    
+
     Can be used as a parameter of an IObjectModifiedEvent."""
 
+
 class IAttributes(IModificationDescription) :
     """ Describes the attributes of an interface.
-   
+
     """
-    
+
     interface = Attribute("The involved interface.")
     attributes = Attribute("A sequence of modified attributes.")
-    
-    
+
+
+class ISequence(IModificationDescription) :
+    """ Describes the modified keys of a sequence-like interface.
+
+    """
+
+    interface = Attribute("The involved interface.")
+    keys = Attribute("A sequence of modified keys.")
+
+
 # BBB: will go in Zope3.3
 
 class IObjectAnnotationsModifiedEvent(IObjectModifiedEvent):
     """An object's annotations have been modified"""
 
+
 class IObjectContentModifiedEvent(IObjectModifiedEvent):
     """An object's content has been modified"""

Modified: Zope3/trunk/src/zope/app/event/objectevent.py
===================================================================
--- Zope3/trunk/src/zope/app/event/objectevent.py	2005-10-08 11:31:46 UTC (rev 38937)
+++ Zope3/trunk/src/zope/app/event/objectevent.py	2005-10-08 11:34:12 UTC (rev 38938)
@@ -74,7 +74,7 @@
 from zope.app.event.interfaces import IObjectCopiedEvent
 from zope.app.event.interfaces import IObjectAnnotationsModifiedEvent
 from zope.app.event.interfaces import IObjectContentModifiedEvent
-from zope.app.event.interfaces import IAttributes
+from zope.app.event.interfaces import IAttributes, ISequence
 from zope.interface import implements
 from zope.event import notify
 from zope.component import subscribers
@@ -89,21 +89,23 @@
 class ObjectEvent(object):
     """Something has happened to an object"""
 
+
     implements(IObjectEvent)
 
     def __init__(self, object):
         self.object = object
 
+
 class ObjectCreatedEvent(ObjectEvent):
     """An object has been created"""
 
     implements(IObjectCreatedEvent)
-    
-    
+
+
 class Attributes(object) :
     """
     Describes modified attributes of an interface.
-    
+
         >>> from zope.app.dublincore.interfaces import IZopeDublinCore
         >>> desc = Attributes(IZopeDublinCore, "title", "description")
         >>> desc.interface == IZopeDublinCore
@@ -112,19 +114,39 @@
         True
 
     """
-    
+
     implements(IAttributes)
-    
+
     def __init__(self, interface, *attributes) :
         self.interface = interface
         self.attributes = attributes
 
 
+class Sequence(object) :
+    """
+    Describes modified keys of an interface.
+    
+        >>> from zope.app.container.interfaces import IContainer
+        >>> desc = Sequence(IContainer, 'foo', 'bar')
+        >>> desc.interface == IContainer
+        True
+        >>> desc.keys
+        ('foo', 'bar')
+
+    """
+    
+    implements(ISequence)
+    
+    def __init__(self, interface, *keys) :
+        self.interface = interface
+        self.keys = keys
+
+
 class ObjectModifiedEvent(ObjectEvent):
     """An object has been modified"""
 
     implements(IObjectModifiedEvent)
-    
+
     def __init__(self, object, *descriptions) :
         """
         Init with a list of modification descriptions.
@@ -146,8 +168,8 @@
 
 def modified(object, *descriptions):
     notify(ObjectModifiedEvent(object, *descriptions))
-    
 
+
 class ObjectCopiedEvent(ObjectCreatedEvent):
     """An object has been copied"""
 
@@ -161,15 +183,13 @@
         pass # getting them does the work
 
 
-
-
 # BBB:  Can go away in 3.3
 
 class ObjectAnnotationsModifiedEvent(ObjectModifiedEvent):
     """An object's annotations have been modified"""
 
     implements(IObjectAnnotationsModifiedEvent)
-    
+
     def __init__(self, object, deprecated_use=True) :
         super(ObjectAnnotationsModifiedEvent, self).__init__(object)
         if deprecated_use :
@@ -179,7 +199,8 @@
                 "and modification descriptors instead."
                 % self.__class__.__name__,
                 DeprecationWarning)
-        
+
+
 def annotationModified(object, deprecated_use=True):
     warnings.warn(
                 "annotationModified is deprecated and will no-longer be "
@@ -190,6 +211,7 @@
                 
     notify(ObjectAnnotationsModifiedEvent(object, deprecated_use=False))
 
+
 class ObjectContentModifiedEvent(ObjectModifiedEvent):
     """An object's content has been modified"""
 
@@ -205,6 +227,7 @@
                 % self.__class__.__name__,
                 DeprecationWarning)
 
+
 def contentModified(object, deprecated_use=True):
     warnings.warn(
                 "contentModified is deprecated and will no-longer be "
@@ -214,5 +237,3 @@
                 DeprecationWarning)
 
     notify(ObjectContentModifiedEvent(object, deprecated_use=False))
-
-



More information about the Zope3-Checkins mailing list