[Zope3-checkins] CVS: Zope3/lib/python/Zope/Event - IObjectEvent.py:1.4 Logger.py:1.3 ObjectEvent.py:1.3
Jim Fulton
jim@zope.com
Thu, 3 Oct 2002 16:53:53 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/Event
In directory cvs.zope.org:/tmp/cvs-serv6678/lib/python/Zope/Event
Modified Files:
IObjectEvent.py Logger.py ObjectEvent.py
Log Message:
Refactored Object events:
- All ObjectEvents now have an object attribute, which is the
the subject of the event.
- Changed the getLocation and getFromLocation methods to location and
fromLocation attributes.
Refactored HubEvents:
- Changed getObject, getRuid, and getLocation methods to object, hid,
and location attributes.
=== Zope3/lib/python/Zope/Event/IObjectEvent.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Event/IObjectEvent.py:1.3 Tue Sep 3 16:12:46 2002
+++ Zope3/lib/python/Zope/Event/IObjectEvent.py Thu Oct 3 16:53:22 2002
@@ -18,42 +18,34 @@
"""
from IEvent import IEvent
+from Interface.Attribute import Attribute
class IObjectEvent(IEvent):
"""Something has happened to an object.
The object that generated this event is not necessarily the object
- refered to by getLocation.
+ refered to by location.
"""
- def getLocation():
- """returns the object location."""
+ object = Attribute("The subject of the event.")
-class IObjectAddedEvent(IObjectEvent):
- """An object has been added to a container."""
+ location = Attribute("An optional object location.")
+
+class IObjectCreatedEvent(IObjectEvent):
+ """An object has been created.
- def getLocation():
- """Returns the object location.
+ The location will usually be None for this event."""
- This is the location after it has been added to the container"""
+class IObjectAddedEvent(IObjectEvent):
+ """An object has been added to a container."""
class IObjectModifiedEvent(IObjectEvent):
"""An object has been modified"""
class IObjectRemovedEvent(IObjectEvent):
"""An object has been removed from a container"""
-
- def getLocation():
- """location of the object before it was removed"""
-
- def getObject():
- """the object that was removed"""
class IObjectMovedEvent(IObjectEvent):
"""An object has been moved"""
- def getFromLocation():
- """location of the object before it was moved"""
-
- def getLocation():
- """location of the object after it was moved"""
+ fromLocation = Attribute("The old location for the object.")
=== Zope3/lib/python/Zope/Event/Logger.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Event/Logger.py:1.2 Mon Jun 10 19:29:25 2002
+++ Zope3/lib/python/Zope/Event/Logger.py Thu Oct 3 16:53:22 2002
@@ -32,7 +32,9 @@
def notify(self, event):
c = event.__class__
detail = StringIO()
- pprint (event.__dict__,detail)
+ data = event.__dict__.items()
+ data.sort()
+ pprint (data, detail)
LOG('Event.Logger',
self.severity,
c.__module__+'.'+c.__name__,
=== Zope3/lib/python/Zope/Event/ObjectEvent.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Event/ObjectEvent.py:1.2 Mon Jun 10 19:29:25 2002
+++ Zope3/lib/python/Zope/Event/ObjectEvent.py Thu Oct 3 16:53:22 2002
@@ -17,54 +17,47 @@
$Id$
"""
+__metaclass__ = type
+
+from IObjectEvent import IObjectEvent, IObjectCreatedEvent
from IObjectEvent import IObjectAddedEvent, IObjectModifiedEvent
from IObjectEvent import IObjectRemovedEvent, IObjectMovedEvent
-class ObjectAddedEvent:
+class ObjectEvent:
"""An object has been added to a container."""
- __implements__ = IObjectAddedEvent
+ __implements__ = IObjectEvent
+
+ object = None
+ location = None
- def __init__(self, location):
- self.__location = location
-
- def getLocation(self):
- """returns the object location after it has been added to the container"""
- return self.__location
+ def __init__(self, object, location=None):
+ self.object = object
+ self.location = location
-class ObjectModifiedEvent(ObjectAddedEvent):
+class ObjectAddedEvent(ObjectEvent):
+ """An object has been added"""
+
+ __implements__ = IObjectAddedEvent
+
+class ObjectModifiedEvent(ObjectEvent):
"""An object has been modified"""
__implements__ = IObjectModifiedEvent
-class ObjectRemovedEvent:
+class ObjectRemovedEvent(ObjectEvent):
"""An object has been removed from a container"""
__implements__ = IObjectRemovedEvent
- def __init__(self, location, obj):
- self.__location = location
- self.__obj = obj
-
- def getLocation(self):
- """returns the location the object was removed from"""
- return self.__location
-
- def getObject(self):
- """returns the object that was removed."""
- return self.__obj
-
-
class ObjectMovedEvent(ObjectAddedEvent):
"""An object has been moved"""
__implements__ = IObjectMovedEvent
- def __init__(self, from_location, location):
- ObjectAddedEvent.__init__(self, location)
- self.__from_location = from_location
-
- def getFromLocation(self):
- """location of the object before it was moved"""
- return self.__from_location
+ fromLocation = None
+
+ def __init__(self, object, from_location, to_location):
+ super(ObjectMovedEvent, self).__init__(object, to_location)
+ self.fromLocation = from_location