[Zope3-checkins] SVN: Zope3/branches/jim-simplifyevents/src/zope/app/ Checkpointing various fixes to branch.

Jim Fulton jim at zope.com
Wed May 26 14:10:32 EDT 2004


Log message for revision 25015:
Checkpointing various fixes to branch.



-=-
Modified: Zope3/branches/jim-simplifyevents/src/zope/app/event/__init__.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/__init__.py	2004-05-26 17:01:20 UTC (rev 25014)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/__init__.py	2004-05-26 18:10:31 UTC (rev 25015)
@@ -1 +1,19 @@
+##############################################################################
 #
+# Copyright (c) 2004 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.0 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""
+
+$Id$
+"""
+
+from dispatching import publish

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/event/dispatching.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/dispatching.py	2004-05-26 17:01:20 UTC (rev 25014)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/dispatching.py	2004-05-26 18:10:31 UTC (rev 25015)
@@ -18,7 +18,7 @@
 
 So, to subscribe to an event, use a subscription adapter to None:
 
-  >>> from zope.app.tests.placelesssetup import SetUp, tearDown
+  >>> from zope.app.tests.placelesssetup import setUp, tearDown
   >>> setUp()
 
   >>> class E1:
@@ -35,8 +35,9 @@
   ...     called.append(2)
 
   >>> from zope.app.tests import ztapi
-  >>> ztapi.subscribe(E1, None, handler1)
-  >>> ztapi.subscribe(E2, None, handler2)
+  >>> from zope.interface import implementedBy
+  >>> ztapi.handle([implementedBy(E1)], handler1)
+  >>> ztapi.handle([implementedBy(E2)], handler2)
 
   >>> from zope.event import notify
 
@@ -54,3 +55,15 @@
 
 $Id$
 """
+
+from zope.component import subscribers
+import zope.event
+
+def dispatch(*event):
+    for ignored in subscribers(event, None):
+        pass
+
+zope.event.subscribers.append(dispatch)
+
+def publish(context, event):
+    zope.event.notify(event)

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/placelesssetup.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/placelesssetup.py	2004-05-26 17:01:20 UTC (rev 25014)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/placelesssetup.py	2004-05-26 18:10:31 UTC (rev 25015)
@@ -17,9 +17,10 @@
 """
 
 from zope.app.event.interfaces import IObjectEvent
-from zope.app.event.objectevent import objectEventNotifierInstance
+from zope.app.event.objectevent import objectEventNotify
 from zope.interface import implements
 from zope.component import getGlobalServices
+from zope.app.tests import ztapi
 
 events = []
 

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_objectevent.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_objectevent.py	2004-05-26 17:01:20 UTC (rev 25014)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/event/tests/test_objectevent.py	2004-05-26 18:10:31 UTC (rev 25015)
@@ -56,24 +56,25 @@
         setUp()
 
     def testNotify(self):
-        notifier = objectevent.ObjectEventNotifier()
         events = []
 
-        ztapi.handle([IContained, IObjectRemovedEvent], events.append)
+        def record(*args):
+            events.append(args)
 
+        ztapi.handle([IContained, IObjectRemovedEvent], record)
+
         item = Contained()
         event = ObjectRemovedEvent(item)
-        notifier.notify(event)
-        self.assertEqual([event], events)
+        objectevent.objectEventNotify(event)
+        self.assertEqual([(item, event)], events)
 
     def testNotifyNobody(self):
         # Check that notify won't raise an exception in absence of
         # of subscribers.
-        notifier = objectevent.ObjectEventNotifier()
         events = []
         item = Contained()
         evt = ObjectRemovedEvent(item)
-        notifier.notify(evt)
+        objectevent.objectEventNotify(evt)
         self.assertEqual([], events)
 
     def testVeto(self):
@@ -87,7 +88,7 @@
         class Veto(Exception):
             pass
         
-        def callback(event):
+        def callback(item, event):
             self.callbackTriggered = True
             self.assertEqual(item, event.object)
             raise Veto

Modified: Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/contentworkflow.py
===================================================================
--- Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/contentworkflow.py	2004-05-26 17:01:20 UTC (rev 25014)
+++ Zope3/branches/jim-simplifyevents/src/zope/app/workflow/stateful/contentworkflow.py	2004-05-26 18:10:31 UTC (rev 25015)
@@ -22,7 +22,7 @@
 
 from zope.app import zapi
 from zope.app.event.interfaces import IObjectCreatedEvent
-from zope.app.servicenames import EventSubscription, Utilities
+from zope.app.servicenames import Utilities
 
 from zope.app.workflow.interfaces import IProcessInstanceContainer
 from zope.app.workflow.interfaces import IProcessInstanceContainerAdaptable




More information about the Zope3-Checkins mailing list