[Zope-Checkins] CVS: Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/tests - EventSetup.py:1.3 testEventService.py:1.3
Jim Fulton
jim@zope.com
Thu, 11 Jul 2002 14:22:02 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/tests
In directory cvs.zope.org:/tmp/cvs-serv7355/lib/python/Zope/App/OFS/Services/LocalEventService/tests
Modified Files:
EventSetup.py testEventService.py
Log Message:
Reimplemented service managers to be package based. Service managers
are no longer containers. They have a packages subobject (not a
packages service) that contains packages. TTW components are created
in packages. To register a component, create the appropriate component
directive objects (these should be called configuration objects).
This should be viewed as a prototype to illustrate the idea of
packages. Lots of things can change (especially UI) and many things
aren't done (e.g. visiting created directives).
In the course of this, I fixed a bunch of bugs and problems in
traversal machinery.
I also renamed Zope.ComponentArchitecture.IServiceManager back to
IServiceService, since this interface doesn't actually specify any
management.
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/tests/EventSetup.py 1.2 => 1.3 ===
from Zope.App.OFS.Services.ServiceManager.tests.PlacefulSetup \
import PlacefulSetup
from Zope.ComponentArchitecture import getService, getServiceManager
+
from Zope.App.Traversing.Traverser import Traverser
from Zope.App.Traversing.ITraverser import ITraverser
from Zope.App.Traversing.DefaultTraversable import DefaultTraversable
from Zope.App.Traversing.ITraversable import ITraversable
+
+
+from Zope.App.Traversing.IPhysicallyLocatable import IPhysicallyLocatable
+from Zope.App.Traversing.IContainmentRoot import IContainmentRoot
+from Zope.App.Traversing.PhysicalLocationAdapters \
+ import WrapperPhysicallyLocatable, RootPhysicallyLocatable
+
+
from Zope.App.OFS.Container.ContainerTraversable import ContainerTraversable
-from Zope.App.OFS.Container.IContainer import IReadContainer
-from Zope.App.OFS.Services.LocalEventService.LocalEventService import LocalEventService
+from Zope.App.OFS.Container.IContainer import ISimpleReadContainer
+
+
+
+from Zope.App.OFS.Services.LocalEventService.LocalEventService \
+ import LocalEventService
+from Zope.App.OFS.Services.ServiceManager.ServiceDirective \
+ import ServiceDirective
+from Zope.App.Traversing import getPhysicalPathString
class EventSetup(PlacefulSetup):
def setUp(self):
PlacefulSetup.setUp(self)
self.buildFolders()
- adapterService=getService(None, "Adapters")
+ adapterService = getService(None, "Adapters")
adapterService.provideAdapter(
None, ITraverser, Traverser)
adapterService.provideAdapter(
None, ITraversable, DefaultTraversable)
adapterService.provideAdapter(
- IReadContainer, ITraversable, ContainerTraversable)
+ ISimpleReadContainer, ITraversable, ContainerTraversable)
+
+ adapterService.provideAdapter(
+ None, IPhysicallyLocatable, WrapperPhysicallyLocatable)
+ adapterService.provideAdapter(
+ IContainmentRoot, IPhysicallyLocatable, RootPhysicallyLocatable)
+
from Zope.Event.IEventService import IEventService
from Zope.Event.GlobalEventService import eventService
globsm=getServiceManager(None)
@@ -51,7 +73,12 @@
if not folder.hasServiceManager():
self.createServiceManager(folder)
sm=getServiceManager(folder) # wrapped now
- sm.setObject("myEventService",LocalEventService())
- sm.bindService("Events","myEventService")
+ sm.Packages['default'].setObject("myEventService",LocalEventService())
+
+ path = "%s/Packages/default/myEventService" % getPhysicalPathString(sm)
+ directive = ServiceDirective("Events", path)
+ sm.Packages['default'].setObject("myEventServiceDir", directive)
+ sm.bindService(directive)
+
=== Zope3/lib/python/Zope/App/OFS/Services/LocalEventService/tests/testEventService.py 1.2 => 1.3 ===
"""
from unittest import TestCase, TestLoader, TextTestRunner
-from EventSetup import EventSetup
+
from Zope.ComponentArchitecture import getService, getServiceManager
-from Zope.App.OFS.Services.LocalEventService.LocalEventService import \
- LocalEventService
-from Zope.Event.tests.subscriber import DummySubscriber, DummyFilter
-from Zope.Event.ObjectEvent import ObjectAddedEvent
-from Zope.Event import subscribe, unsubscribe, listSubscriptions, publishEvent
+from Zope.Proxy.ContextWrapper import ContextWrapper
+
+from Zope.Exceptions import NotFoundError
+
+from Zope.App.OFS.Services.LocalEventService.LocalEventService \
+ import LocalEventService
+
+from Zope.App.OFS.Services.ServiceManager.ServiceDirective \
+ import ServiceDirective
+
+from Zope.App.Traversing import getPhysicalPathString
+
+from Zope.Event import subscribe, unsubscribe, listSubscriptions, publishEvent
+from Zope.Event.tests.subscriber import DummySubscriber, DummyFilter
from Zope.Event.IObjectEvent import IObjectEvent
from Zope.Event.IObjectEvent import IObjectAddedEvent
from Zope.Event.IObjectEvent import IObjectRemovedEvent
from Zope.Event.IObjectEvent import IObjectModifiedEvent
from Zope.Event.ObjectEvent import ObjectAddedEvent, ObjectModifiedEvent
+from Zope.Event.ObjectEvent import ObjectAddedEvent
from Zope.Event.GlobalEventService import GlobalEventService
-from Zope.Exceptions import NotFoundError
from Zope.Event.IEvent import IEvent
-from Zope.Proxy.ContextWrapper import ContextWrapper
-from Zope.Event.tests.subscriber import DummySubscriber, DummyFilter
+from EventSetup import EventSetup
class UnpromotingLocalEventService(LocalEventService):
@@ -366,8 +374,13 @@
if not self.folder2.hasServiceManager():
self.createServiceManager(self.folder2)
sm=getServiceManager(self.folder2) # wrapped now
- sm.setObject("myEventService",service) # this is the change
- sm.bindService("Events","myEventService")
+ sm.Packages['default'].setObject("myEventService", service)
+
+ path = "%s/Packages/default/myEventService" % getPhysicalPathString(sm)
+ directive = ServiceDirective("Events", path)
+ sm.Packages['default'].setObject("myEventServiceDir", directive)
+ sm.bindService(directive)
+
subscribe(
self.rootFolderSubscriber,
event_type=IObjectAddedEvent
@@ -411,7 +424,8 @@
event_type=IObjectAddedEvent
)
sm=getServiceManager(self.folder1)
- sm.unbindService("Events")
+ directive = sm.getDirectives("Events")[0]
+ sm.unbindService(directive)
publishEvent(self.rootFolder, ObjectAddedEvent('/foo'))
self.assertEqual(self.folder1Subscriber.notified, 0)
self.assertEqual(self.folder1_1Subscriber.notified, 1)
@@ -426,7 +440,8 @@
self.assertEqual(self.folder2Subscriber.notified, 0)
self.assertEqual(self.rootFolderSubscriber.notified, 1)
sm=getServiceManager(self.folder2)
- sm.unbindService("Events") # make sure it doesn't raise any errors
+ directive = sm.getDirectives("Events")[0]
+ sm.unbindService(directive) # make sure it doesn't raise any errors