Log message for revision 74025:
  Merged trunk r74023:74024 into 2.10 branch.
  
  Configure subscribers in code, not by loading ZCML.
  

Changed:
  D   Zope/branches/2.10/lib/python/OFS/tests/events.zcml
  U   Zope/branches/2.10/lib/python/OFS/tests/testCopySupportEvents.py

-=-
Deleted: Zope/branches/2.10/lib/python/OFS/tests/events.zcml
===================================================================
--- Zope/branches/2.10/lib/python/OFS/tests/events.zcml 2007-04-05 17:21:57 UTC 
(rev 74024)
+++ Zope/branches/2.10/lib/python/OFS/tests/events.zcml 2007-04-05 17:25:52 UTC 
(rev 74025)
@@ -1,112 +0,0 @@
-<configure
-    xmlns="http://namespaces.zope.org/zope";
-    i18n_domain="extfile">
-
-  <!-- Item -->
-
-  <subscriber
-    handler=".testCopySupportEvents.objectAddedEvent"
-    for=".testCopySupportEvents.ITestItem
-         zope.app.container.interfaces.IObjectAddedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectCopiedEvent"
-    for=".testCopySupportEvents.ITestItem
-         zope.lifecycleevent.interfaces.IObjectCopiedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectMovedEvent"
-    for=".testCopySupportEvents.ITestItem
-         zope.app.container.interfaces.IObjectMovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectRemovedEvent"
-    for=".testCopySupportEvents.ITestItem
-         zope.app.container.interfaces.IObjectRemovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectWillBeAddedEvent"
-    for=".testCopySupportEvents.ITestItem
-         OFS.interfaces.IObjectWillBeAddedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectWillBeMovedEvent"
-    for=".testCopySupportEvents.ITestItem
-         OFS.interfaces.IObjectWillBeMovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectWillBeRemovedEvent"
-    for=".testCopySupportEvents.ITestItem
-         OFS.interfaces.IObjectWillBeRemovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectClonedEvent"
-    for=".testCopySupportEvents.ITestItem
-         OFS.interfaces.IObjectClonedEvent"
-    />
-
-  <!-- Folder -->
-
-  <subscriber
-    handler=".testCopySupportEvents.objectAddedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         zope.app.container.interfaces.IObjectAddedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectCopiedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         zope.lifecycleevent.interfaces.IObjectCopiedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectMovedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         zope.app.container.interfaces.IObjectMovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectRemovedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         zope.app.container.interfaces.IObjectRemovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.containerModifiedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         zope.app.container.interfaces.IContainerModifiedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectWillBeAddedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         OFS.interfaces.IObjectWillBeAddedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectWillBeMovedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         OFS.interfaces.IObjectWillBeMovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectWillBeRemovedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         OFS.interfaces.IObjectWillBeRemovedEvent"
-    />
-
-  <subscriber
-    handler=".testCopySupportEvents.objectClonedEvent"
-    for=".testCopySupportEvents.ITestFolder
-         OFS.interfaces.IObjectClonedEvent"
-    />
-
-</configure>
-

Modified: Zope/branches/2.10/lib/python/OFS/tests/testCopySupportEvents.py
===================================================================
--- Zope/branches/2.10/lib/python/OFS/tests/testCopySupportEvents.py    
2007-04-05 17:21:57 UTC (rev 74024)
+++ Zope/branches/2.10/lib/python/OFS/tests/testCopySupportEvents.py    
2007-04-05 17:25:52 UTC (rev 74025)
@@ -3,7 +3,6 @@
 import Zope2
 Zope2.startup()
 
-import os
 import transaction
 
 from Testing.makerequest import makerequest
@@ -15,14 +14,19 @@
 from OFS.Folder import Folder
 
 from zope import interface
+from zope import component
 from zope.app.container.interfaces import IObjectAddedEvent
+from zope.app.container.interfaces import IObjectMovedEvent
 from zope.app.container.interfaces import IObjectRemovedEvent
+from zope.app.container.interfaces import IContainerModifiedEvent
+from zope.lifecycleevent.interfaces import IObjectCopiedEvent
 from OFS.interfaces import IObjectWillBeAddedEvent
+from OFS.interfaces import IObjectWillBeMovedEvent
 from OFS.interfaces import IObjectWillBeRemovedEvent
+from OFS.interfaces import IObjectClonedEvent
 
 from zope.testing import cleanup
 from Products.Five import zcml
-from Globals import package_home
 
 
 class EventLogger(object):
@@ -58,8 +62,6 @@
         pass # Always allow
 
 
-# See events.zcml
-
 def objectAddedEvent(ob, event):
     eventlog.trace(ob, 'ObjectAddedEvent')
 
@@ -96,6 +98,21 @@
     eventlog.trace(ob, 'ObjectClonedEvent')
 
 
+def setUpItemSubscribers(interface):
+    component.provideHandler(objectAddedEvent, (interface, IObjectAddedEvent))
+    component.provideHandler(objectCopiedEvent, (interface, 
IObjectCopiedEvent))
+    component.provideHandler(objectMovedEvent, (interface, IObjectMovedEvent))
+    component.provideHandler(objectRemovedEvent, (interface, 
IObjectRemovedEvent))
+    component.provideHandler(objectWillBeAddedEvent, (interface, 
IObjectWillBeAddedEvent))
+    component.provideHandler(objectWillBeMovedEvent, (interface, 
IObjectWillBeMovedEvent))
+    component.provideHandler(objectWillBeRemovedEvent, (interface, 
IObjectWillBeRemovedEvent))
+    component.provideHandler(objectClonedEvent, (interface, 
IObjectClonedEvent))
+
+def setUpFolderSubscribers(interface):
+    setUpItemSubscribers(interface)
+    component.provideHandler(containerModifiedEvent, (interface, 
IContainerModifiedEvent))
+
+
 class EventLayer:
 
     @classmethod
@@ -103,9 +120,8 @@
         cleanup.cleanUp()
         zcml._initialized = 0
         zcml.load_site()
-        import OFS.tests
-        file = os.path.join(package_home(globals()), 'events.zcml')
-        zcml.load_config(file, package=OFS.tests)
+        setUpItemSubscribers(ITestItem)
+        setUpFolderSubscribers(ITestFolder)
 
     @classmethod
     def tearDown(cls):

_______________________________________________
Zope-Checkins maillist  -  Zope-Checkins@zope.org
http://mail.zope.org/mailman/listinfo/zope-checkins

Reply via email to