[Zope3-checkins] CVS: Zope3/lib/python/Zope/Event/tests - PlacelessSetup.py:1.3 testEventService.py:1.6 testLogger.py:1.7

Steve Alexander steve@cat-box.net
Thu, 5 Dec 2002 12:20:30 -0500


Update of /cvs-repository/Zope3/lib/python/Zope/Event/tests
In directory cvs.zope.org:/tmp/cvs-serv3454/lib/python/Zope/Event/tests

Modified Files:
	PlacelessSetup.py testEventService.py testLogger.py 
Log Message:
Refactored global event service to have a different interface than the
placeful event service.

Now, you must use a different method to subscribe to the global service.
This stops inadvertant subscriptions of persistent placeful objects
to the global event service. Such a subscription would be bad, because
the subscription would not be remembered on a zope restart.


=== Zope3/lib/python/Zope/Event/tests/PlacelessSetup.py 1.2 => 1.3 ===
--- Zope3/lib/python/Zope/Event/tests/PlacelessSetup.py:1.2	Fri Oct  4 16:07:09 2002
+++ Zope3/lib/python/Zope/Event/tests/PlacelessSetup.py	Thu Dec  5 12:20:29 2002
@@ -54,4 +54,4 @@
         provideService("Events", eventService)
         
         del events[:]
-        eventService.subscribe(EventRecorder)
+        eventService.globalSubscribe(EventRecorder)


=== Zope3/lib/python/Zope/Event/tests/testEventService.py 1.5 => 1.6 ===
--- Zope3/lib/python/Zope/Event/tests/testEventService.py:1.5	Sun Dec  1 05:32:29 2002
+++ Zope3/lib/python/Zope/Event/tests/testEventService.py	Thu Dec  5 12:20:29 2002
@@ -49,13 +49,13 @@
         
     def testSubscribe1(self):
         "Test subscribe method with one parameter"
-        self.service.subscribe(self.subscriber)
+        self.service.globalSubscribe(self.subscriber)
         self.service.publish(self.event)
         self.assertEqual(self.subscriber.notified, 1)
         
     def testSubscribe2(self):
         "Test subscribe method with two parameters"
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent
             )
@@ -64,7 +64,7 @@
 
     def testSubscribe3(self):
         "Test subscribe method with three parameters"
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent,
             filter=DummyFilter()
@@ -76,7 +76,7 @@
         """Test subscribe method with three parameters
         and an always failing filter.
         """
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent,
             filter=DummyFilter(0)
@@ -88,7 +88,7 @@
         """Test subscribe method with three parameters
         and an irrelevent event type.
         """
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectModifiedEvent,
             filter=DummyFilter()
@@ -101,7 +101,7 @@
         registered is a generalised interface of the
         event passed to the 'publish' method.
         """
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectEvent
             )
@@ -113,11 +113,11 @@
         event types registered is not interested in
         the published event.
         """
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectModifiedEvent
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent
             )
@@ -128,17 +128,17 @@
         """Test subscribe method where the same subscriber
         subscribes multiple times. 
         """
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent,
             filter=DummyFilter()
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent,
             filter=DummyFilter()
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent,
             filter=DummyFilter(0)
@@ -149,7 +149,7 @@
     def testUnsubscribe1(self):
         "Test unsubscribe method"
         subscriber = self.subscriber
-        self.service.subscribe(subscriber)
+        self.service.globalSubscribe(subscriber)
         self.service.publish(self.event)
         self.assertEqual(self.subscriber.notified, 1)
         self.service.unsubscribe(subscriber)
@@ -170,18 +170,18 @@
         subscriber2=DummySubscriber()
         filter=DummyFilter()
         event2=ObjectModifiedEvent(None, '/foo')
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber)
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent,
             filter=filter
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             subscriber2,
             event_type=IObjectAddedEvent
             )
@@ -213,7 +213,7 @@
     def testpublish1(self):
         "Test publish method"
         subscriber = self.subscriber
-        self.service.subscribe(subscriber)
+        self.service.globalSubscribe(subscriber)
         self.assertEqual(self.subscriber.notified, 0)        
         self.service.publish(self.event)
         self.assertEqual(self.subscriber.notified, 1)
@@ -225,11 +225,11 @@
         in the second subscription.
         """
         subscriber = self.subscriber
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectEvent,
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent,
             )
@@ -242,11 +242,11 @@
         of those interfaces.
         """
         subscriber = self.subscriber
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectRemovedEvent
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent
             )
@@ -258,11 +258,11 @@
         'leak registrations up' sez Jim.
         """
         subscriber = self.subscriber
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectEvent
             )
-        self.service.subscribe(
+        self.service.globalSubscribe(
             self.subscriber,
             event_type=IObjectAddedEvent
             )
@@ -275,13 +275,15 @@
     
     def testListSubscriptions2(self):
         "one subscription"
-        self.service.subscribe(self.subscriber, event_type=IObjectAddedEvent)
+        self.service.globalSubscribe(
+                self.subscriber, event_type=IObjectAddedEvent)
         self.assertEqual([(IObjectAddedEvent, None)],
                          self.service.listSubscriptions(self.subscriber))
     
     def testListSubscriptions3(self):
         "listing limited subscription"
-        self.service.subscribe(self.subscriber, event_type=IObjectAddedEvent)
+        self.service.globalSubscribe(
+                self.subscriber, event_type=IObjectAddedEvent)
         L = self.service.listSubscriptions(self.subscriber,
                                            IObjectRemovedEvent)
         self.assertEqual([], L)


=== Zope3/lib/python/Zope/Event/tests/testLogger.py 1.6 => 1.7 ===
--- Zope3/lib/python/Zope/Event/tests/testLogger.py:1.6	Thu Dec  5 08:44:11 2002
+++ Zope3/lib/python/Zope/Event/tests/testLogger.py	Thu Dec  5 12:20:29 2002
@@ -21,7 +21,7 @@
 from Zope.ComponentArchitecture.tests.PlacelessSetup import PlacelessSetup
 from Zope.ComponentArchitecture import getServiceManager, getService
 
-from Zope.Event import subscribe, unsubscribe, publish
+from Zope.Event import globalSubscribe, unsubscribe, publish
 from Zope.Event.ObjectEvent import ObjectAddedEvent
 from Zope.Event.Logger import Logger
 
@@ -53,7 +53,7 @@
         self.logger = DopeyLogger()
         zLOG.log_write = self.logger.log_write
         # register a logger
-        subscribe(self.eventlogger)
+        globalSubscribe(self.eventlogger)
         # send an event
         publish(None, ObjectAddedEvent(None, 'foo'))