[Zope3-checkins] CVS: Zope3/lib/python/Zope/Event - ObjectEvent.py:1.8 Logger.py:1.4
Steve Alexander
steve@cat-box.net
Thu, 5 Dec 2002 08:44:15 -0500
Update of /cvs-repository/Zope3/lib/python/Zope/Event
In directory cvs.zope.org:/tmp/cvs-serv31379/lib/python/Zope/Event
Modified Files:
ObjectEvent.py Logger.py
Log Message:
Make the ObjectEvent base class smarter about getting you a location
if it is not provided originally.
Disabled some of the features of the Logger that depended on details
of the Event object implementations, not their interfaces.
This needs to be refactored later, using adapters to get an appropriate
logging presentation for an event.
=== Zope3/lib/python/Zope/Event/ObjectEvent.py 1.7 => 1.8 ===
--- Zope3/lib/python/Zope/Event/ObjectEvent.py:1.7 Thu Dec 5 07:54:32 2002
+++ Zope3/lib/python/Zope/Event/ObjectEvent.py Thu Dec 5 08:44:13 2002
@@ -22,20 +22,30 @@
from IObjectEvent import IObjectEvent, IObjectCreatedEvent
from IObjectEvent import IObjectAddedEvent, IObjectModifiedEvent
from IObjectEvent import IObjectRemovedEvent, IObjectMovedEvent
-from IObjectEvent import IObjectContentModifiedEvent, \
- IObjectAnnotationsModifiedEvent
+from IObjectEvent \
+ import IObjectContentModifiedEvent, IObjectAnnotationsModifiedEvent
+
+# XXX: this is a dependency on Zope.App.... so we need to move
+# these event definitions into there.
+from Zope.App.Traversing import getPhysicalPath
+
+_marker = object()
class ObjectEvent:
"""Something has happened to an object"""
__implements__ = IObjectEvent
- object = None
- location = None
+ def _getLocation(self):
+ if self.__location is not _marker:
+ return self.__location
+ return getPhysicalPath(self.object)
+
+ location = property(_getLocation)
- def __init__(self, object, location=None):
+ def __init__(self, object, location=_marker):
self.object = object
- self.location = location
+ self.__location = location
class ObjectAddedEvent(ObjectEvent):
"""An object has been added to a container"""
=== Zope3/lib/python/Zope/Event/Logger.py 1.3 => 1.4 ===
--- Zope3/lib/python/Zope/Event/Logger.py:1.3 Thu Oct 3 16:53:22 2002
+++ Zope3/lib/python/Zope/Event/Logger.py Thu Dec 5 08:44:13 2002
@@ -32,9 +32,10 @@
def notify(self, event):
c = event.__class__
detail = StringIO()
- data = event.__dict__.items()
- data.sort()
- pprint (data, detail)
+ #data = event.__dict__.items()
+ #data.sort()
+ #pprint(data, detail)
+ print >>detail, 'XXX detail temporarily disabled'
LOG('Event.Logger',
self.severity,
c.__module__+'.'+c.__name__,