Commit 42f7f1fa authored by Stefan H. Holek's avatar Stefan H. Holek

Merged trunk r74023:74024 into 2.9 branch.

Configure subscribers in code, not by loading ZCML.
parent b9e70680
<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.app.event.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.app.event.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>
......@@ -3,7 +3,6 @@ import Testing
import Zope2
Zope2.startup()
import os
import transaction
from Testing.makerequest import makerequest
......@@ -15,14 +14,19 @@ from OFS.SimpleItem import SimpleItem
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 @@ class TestFolder(Folder):
pass # Always allow
# See events.zcml
def objectAddedEvent(ob, event):
eventlog.trace(ob, 'ObjectAddedEvent')
......@@ -96,6 +98,21 @@ def objectClonedEvent(ob, event):
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 @@ class EventLayer:
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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment