[Zope3-checkins] CVS: Zope3/src/zope/app/tentative - event.py:1.1.2.3

Nathan Yergler nathan at yergler.net
Tue Apr 6 12:17:50 EDT 2004


Update of /cvs-repository/Zope3/src/zope/app/tentative
In directory cvs.zope.org:/tmp/cvs-serv20571/src/zope/app/tentative

Modified Files:
      Tag: tentative-branch
	event.py 
Log Message:


Added initial doctests; fixed calls to republish tentative and confirmed events.




=== Zope3/src/zope/app/tentative/event.py 1.1.2.2 => 1.1.2.3 ===
--- Zope3/src/zope/app/tentative/event.py:1.1.2.2	Thu Apr  1 09:07:07 2004
+++ Zope3/src/zope/app/tentative/event.py	Tue Apr  6 12:17:49 2004
@@ -16,12 +16,24 @@
 $Id$
 """
 
+from zope.app.event import publish
 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:
+    """
+    A tentative event wraps an existing object event and provides an
+    attribute, issues, which holds a list of potential issues that
+    subscribers have with the event.
+
+    For example:
+    >>> some_event = None
+    >>> tevent = TentativeEvent(some_event)
+    >>> tevent.issues
+    []
+    
+    """
     implements(IEvent)
     
     def __init__(self, objectEvent):
@@ -29,6 +41,21 @@
         self.issues = []
         
 class ConfirmedEvent:
+    """
+    A confirmed event wraps an existing object event and a list of
+    resolved issues.  A confirmed event exposes those issues through the
+    issues attribute.  It is the responsibility of the subscriber to
+    make sure that all issues raised by the execution of the objectEvent
+    are contained in the list of issues which have been resolved by
+    the user.
+
+    >>> some_event = None
+    >>> issues = ['a', 'b']
+    >>> cevent = ConfirmedEvent(some_event, issues)
+    >>> cevent.issues
+    ['a', 'b']
+    
+    """
     implements(IEvent)
     
     def __init__(self, objectEvent, resolvedIssues):
@@ -55,13 +82,16 @@
         
         # first wrap and publish the event as tentative
         tentative = TentativeEvent(event)
-        publish(tentative)
+        # XXX: rip out context argument (None) when new event API is done
+        publish(None, 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)
+            
+            # XXX: rip out context argument (None) when new event API is done
+            publish(None, confirmed)
         else:
             # issues exist, raise an exception
             raise EventIssues(tentative)




More information about the Zope3-Checkins mailing list