[Zope3-checkins] CVS: Zope3/src/zope/app/tentative -
event.py:1.1.2.2
Nathan Yergler
nathan at yergler.net
Thu Apr 1 09:07:08 EST 2004
Update of /cvs-repository/Zope3/src/zope/app/tentative
In directory cvs.zope.org:/tmp/cvs-serv7784/src/zope/app/tentative
Modified Files:
Tag: tentative-branch
event.py
Log Message:
Fleshed out event channel.
=== Zope3/src/zope/app/tentative/event.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zope/app/tentative/event.py:1.1.2.1 Thu Apr 1 08:18:54 2004
+++ Zope3/src/zope/app/tentative/event.py Thu Apr 1 09:07:07 2004
@@ -17,24 +17,54 @@
"""
from zope.app.event.interfaces import ISubscriber
+from zope.app.event.interfaces import IEvent
from zope.app.observable.interfaces import IObservable
from zope.interface import implements
class TentativeEvent:
- pass
-
+ implements(IEvent)
+
+ def __init__(self, objectEvent):
+ self.event = objectEvent
+ self.issues = []
+
class ConfirmedEvent:
- pass
-
+ implements(IEvent)
+
+ def __init__(self, objectEvent, resolvedIssues):
+ self.event = objectEvent
+ self.issues = resolvedIssues
+
+class EventIssues(Exception):
+ def __init__(self, tentativeEvent):
+ self.tentative = tentativeEvent
+ self.event = self.tentative.event
+ self.issues = self.tentative.issues
+
class TentativeEventNotifier:
implements(ISubscriber)
def notify (self, event):
- adapter = IObservable(event.object, None)
- if adapter is not None:
- adapter.notify(event, ISubscriber)
+ # make sure this isn't a tentative or confirmed event
+ # (we ignore those because we generated them)
+ if isinstance(event, TentativeEvent) or \
+ isinstance(event, ConfirmedEvent):
+ return
+
+ # first wrap and publish the event as tentative
+ tentative = TentativeEvent(event)
+ publish(tentative)
+
+ # check for any issues
+ if len(tentative.issues) == 0:
+ # no issues, go ahead and publish as confirmed
+ confirmed = ConfirmedEvent(event, tentative.issues)
+ publish(confirmed)
+ else:
+ # issues exist, raise an exception
+ raise EventIssues(tentative)
tentativeEventNotifierInstance = TentativeEventNotifier()
More information about the Zope3-Checkins
mailing list