[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/ Re-separated
component and event setup. It would be nice to combine
Jim Fulton
jim at zope.com
Wed Apr 26 18:28:31 EDT 2006
Log message for revision 67628:
Re-separated component and event setup. It would be nice to combine
these, but if we do, we need to put them in an entirely new API,
deprecating the old apis. Existing software may use the component
setup and then new it's own setup for objectEventNotify. If the
component setup sets up this handler, then it will be doubly setup,
causing tests to fail.
Changed:
U Zope3/branches/jim-adapter/src/buddydemo/tests.py
U Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt
U Zope3/branches/jim-adapter/src/zope/app/appsetup/bootstrap.txt
U Zope3/branches/jim-adapter/src/zope/app/authentication/groupfolder.txt
U Zope3/branches/jim-adapter/src/zope/app/authentication/principalfolder.py
U Zope3/branches/jim-adapter/src/zope/app/authentication/tests.py
U Zope3/branches/jim-adapter/src/zope/app/component/site.txt
U Zope3/branches/jim-adapter/src/zope/app/container/contained.py
U Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectcopier.py
U Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectmover.py
U Zope3/branches/jim-adapter/src/zope/app/container/tests/test_ordered.py
U Zope3/branches/jim-adapter/src/zope/app/event/tests/placelesssetup.py
U Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_add.py
U Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_editview.py
U Zope3/branches/jim-adapter/src/zope/app/testing/placelesssetup.py
U Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py
U Zope3/branches/jim-adapter/src/zope/app/workflow/stateful/tests/test_instance.py
A Zope3/branches/jim-adapter/src/zope/component/eventtesting.py
U Zope3/branches/jim-adapter/src/zope/component/testing.py
U Zope3/branches/jim-adapter/src/zope/component/tests.py
U Zope3/branches/jim-adapter/src/zope/copypastemove/tests/test_rename.py
-=-
Modified: Zope3/branches/jim-adapter/src/buddydemo/tests.py
===================================================================
--- Zope3/branches/jim-adapter/src/buddydemo/tests.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/buddydemo/tests.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -79,7 +79,7 @@
There should be an ObjectModifiedEvent event logged:
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> from zope.lifecycleevent.interfaces \
... import IObjectModifiedEvent
>>> [event] = getEvents(IObjectModifiedEvent)
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/component.txt 2006-04-26 22:28:30 UTC (rev 67628)
@@ -49,9 +49,7 @@
AdapterRegistration(<BaseGlobalComponents base>,
[IFoo], IResult, '', None, u''),
HandlerRegistration(<BaseGlobalComponents base>,
- [IFoo], u'', 'stubFactory', u''),
- HandlerRegistration(<BaseGlobalComponents base>,
- [Interface], u'', append, u'')]
+ [IFoo], u'', 'stubFactory', u'')]
Note how the adapter requiring an `IRequest` at the end of the required
interfaces is neglected. This is because it is recognized as a view and views
@@ -67,9 +65,7 @@
AdapterRegistration(<BaseGlobalComponents base>,
[IFoo], IResult, '', None, u''),
HandlerRegistration(<BaseGlobalComponents base>,
- [IFoo], u'', 'stubFactory', u''),
- HandlerRegistration(<BaseGlobalComponents base>,
- [Interface], u'', append, u'')]
+ [IFoo], u'', 'stubFactory', u'')]
The function will also pick up registrations that have required interfaces the
specified interface extends:
@@ -82,9 +78,7 @@
AdapterRegistration(<BaseGlobalComponents base>,
[IFoo], IResult, '', None, u''),
HandlerRegistration(<BaseGlobalComponents base>,
- [IFoo], u'', 'stubFactory', u''),
- HandlerRegistration(<BaseGlobalComponents base>,
- [Interface], u'', append, u'')]
+ [IFoo], u'', 'stubFactory', u'')]
And all of the required interfaces are considered, of course:
@@ -92,9 +86,7 @@
>>> regs.sort()
>>> regs
[AdapterRegistration(<BaseGlobalComponents base>,
- [IFoo, IBar], ISpecialResult, '', None, u''),
- HandlerRegistration(<BaseGlobalComponents base>,
- [Interface], u'', append, u'')]
+ [IFoo, IBar], ISpecialResult, '', None, u'')]
`getProvidedAdapters(iface, withViews=False)`
Modified: Zope3/branches/jim-adapter/src/zope/app/appsetup/bootstrap.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/appsetup/bootstrap.txt 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/appsetup/bootstrap.txt 2006-04-26 22:28:30 UTC (rev 67628)
@@ -24,7 +24,7 @@
A DatabaseOpenedWithRoot is generated with the database.
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> [event] = getEvents(interfaces.IDatabaseOpenedWithRootEvent)
>>> event.database is db
True
Modified: Zope3/branches/jim-adapter/src/zope/app/authentication/groupfolder.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/authentication/groupfolder.txt 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/authentication/groupfolder.txt 2006-04-26 22:28:30 UTC (rev 67628)
@@ -19,7 +19,7 @@
Note that when group-info is added, a GroupAdded event is generated:
>>> from zope.app.authentication import interfaces
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> getEvents(interfaces.IGroupAdded)
[<GroupAdded 'group.g1'>]
Modified: Zope3/branches/jim-adapter/src/zope/app/authentication/principalfolder.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/authentication/principalfolder.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/authentication/principalfolder.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -461,7 +461,7 @@
It also fires an AuthenticatedPrincipalCreatedEvent:
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> [event] = getEvents(interfaces.IAuthenticatedPrincipalCreated)
>>> event.principal is principal, event.authentication is auth
(True, True)
@@ -524,7 +524,7 @@
It also fires a FoundPrincipalCreatedEvent:
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> [event] = getEvents(interfaces.IFoundPrincipalCreated)
>>> event.principal is principal, event.authentication is auth
(True, True)
Modified: Zope3/branches/jim-adapter/src/zope/app/authentication/tests.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/authentication/tests.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/authentication/tests.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -22,7 +22,7 @@
from zope.testing import doctest
from zope.interface import implements
from zope.component import provideUtility, provideAdapter
-from zope.component.testing import getEvents, clearEvents
+from zope.component.eventtesting import getEvents, clearEvents
from zope.publisher.interfaces import IRequest
from zope.publisher.tests.httprequest import TestRequest
Modified: Zope3/branches/jim-adapter/src/zope/app/component/site.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/site.txt 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/component/site.txt 2006-04-26 22:28:30 UTC (rev 67628)
@@ -52,7 +52,7 @@
Note that an event is generated when a local site manager is created:
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> from zope.app.component.interfaces import INewLocalSite
>>> [event] = getEvents(INewLocalSite)
>>> event.manager is sm
Modified: Zope3/branches/jim-adapter/src/zope/app/container/contained.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/container/contained.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/container/contained.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -406,7 +406,7 @@
If we run this using the testing framework, we'll use `getEvents` to
track the events generated:
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent
We have an added event:
@@ -601,7 +601,7 @@
If we run this using the testing framework, we'll use `getEvents` to
track the events generated:
- >>> from zope.component.testing import getEvents
+ >>> from zope.component.eventtesting import getEvents
>>> from zope.lifecycleevent.interfaces import IObjectModifiedEvent
>>> from zope.app.container.interfaces import IObjectRemovedEvent
Modified: Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectcopier.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectcopier.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectcopier.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -20,7 +20,7 @@
import zope.component
from zope.testing import doctest
from zope.traversing.api import traverse
-from zope.component.testing import getEvents, clearEvents
+from zope.component.eventtesting import getEvents, clearEvents
from zope.copypastemove import ObjectCopier
from zope.copypastemove.interfaces import IObjectCopier
Modified: Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectmover.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectmover.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/container/tests/test_objectmover.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -20,7 +20,7 @@
import zope.component
from zope.testing import doctest
from zope.traversing.api import traverse
-from zope.component.testing import getEvents, clearEvents
+from zope.component.eventtesting import getEvents, clearEvents
from zope.copypastemove import ObjectMover
from zope.copypastemove.interfaces import IObjectMover
Modified: Zope3/branches/jim-adapter/src/zope/app/container/tests/test_ordered.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/container/tests/test_ordered.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/container/tests/test_ordered.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -17,7 +17,7 @@
"""
import unittest
from zope.testing.doctestunit import DocTestSuite
-from zope.component.testing import getEvents, clearEvents
+from zope.component.eventtesting import getEvents, clearEvents
from zope.app.testing import placelesssetup, setup
def test_order_events():
Modified: Zope3/branches/jim-adapter/src/zope/app/event/tests/placelesssetup.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/event/tests/placelesssetup.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/event/tests/placelesssetup.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -1,7 +1,7 @@
-# This module has moved to zope.component.testing
+# This module has moved to zope.component.eventtesting
# and will go away in Zope 3.5
import zope.deprecation
zope.deprecation.moved(
- 'zope.component.testing',
+ 'zope.component.eventtesting',
"Zope 3.5",
)
Modified: Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_add.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_add.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_add.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -27,7 +27,7 @@
from zope.publisher.interfaces.browser import IDefaultBrowserLayer
from zope.schema import TextLine, accessors
from zope.security.checker import CheckerPublic
-from zope.component.testing import getEvents
+from zope.component.eventtesting import getEvents
from zope.lifecycleevent.interfaces import IObjectCreatedEvent, IObjectModifiedEvent
from zope.app.component.site import SiteManagerAdapter
Modified: Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_editview.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_editview.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/form/browser/tests/test_editview.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -22,7 +22,7 @@
from zope.schema import TextLine, accessors
from zope.schema.interfaces import ITextLine
from zope.component.interfaces import ComponentLookupError
-from zope.component.testing import getEvents, clearEvents
+from zope.component.eventtesting import getEvents, clearEvents
from zope.location.interfaces import ILocation
from zope.app.testing import ztapi
Modified: Zope3/branches/jim-adapter/src/zope/app/testing/placelesssetup.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/testing/placelesssetup.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/testing/placelesssetup.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -17,6 +17,7 @@
"""
from zope.schema.vocabulary import setVocabularyRegistry
from zope.component.testing import PlacelessSetup as CAPlacelessSetup
+from zope.component.eventtesting import PlacelessSetup as EventPlacelessSetup
from zope.i18n.testing import PlacelessSetup as I18nPlacelessSetup
from zope.traversing.browser.interfaces import IAbsoluteURL
from zope.traversing.browser.absoluteurl import AbsoluteURL
@@ -29,12 +30,14 @@
from zope.app.security._protections import protect
class PlacelessSetup(CAPlacelessSetup,
+ EventPlacelessSetup,
I18nPlacelessSetup,
ContainerPlacelessSetup,
AuthenticationPlacelessSetup):
def setUp(self, doctesttest=None):
CAPlacelessSetup.setUp(self)
+ EventPlacelessSetup.setUp(self)
ContainerPlacelessSetup.setUp(self)
I18nPlacelessSetup.setUp(self)
AuthenticationPlacelessSetup.setUp(self)
Modified: Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/versioncontrol/tests.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -26,6 +26,7 @@
import zope.annotation.interfaces
import zope.annotation.attribute
import zope.component.testing
+import zope.component.eventtesting
from zope import interface
from zope.testing import doctest, module
@@ -36,6 +37,7 @@
def setUp(test):
zope.component.testing.setUp(test)
+ zope.component.eventtesting.setUp(test)
module.setUp(test, name)
def tearDown(test):
Modified: Zope3/branches/jim-adapter/src/zope/app/workflow/stateful/tests/test_instance.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/workflow/stateful/tests/test_instance.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/app/workflow/stateful/tests/test_instance.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -26,7 +26,7 @@
from zope.security.interfaces import IPermission
from zope.security.permission import Permission
from zope.annotation.interfaces import IAttributeAnnotatable
-from zope.component.testing import events, clearEvents
+from zope.component.eventtesting import events, clearEvents
from zope.app.workflow.tests.workflowsetup import WorkflowSetup
from zope.app.workflow.interfaces import IProcessDefinition
Added: Zope3/branches/jim-adapter/src/zope/component/eventtesting.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/eventtesting.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/component/eventtesting.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -0,0 +1,54 @@
+##############################################################################
+#
+# Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (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.
+#
+##############################################################################
+"""Placeless Test Setup
+
+$Id$
+"""
+from zope.component import provideHandler
+from zope.component.event import objectEventNotify
+from zope.component.registry import dispatchUtilityRegistrationEvent
+from zope.component.registry import dispatchAdapterRegistrationEvent
+from zope.component.registry import (
+ dispatchSubscriptionAdapterRegistrationEvent)
+from zope.component.registry import dispatchHandlerRegistrationEvent
+from zope.testing import cleanup
+
+events = []
+def getEvents(event_type=None, filter=None):
+ r = []
+ for event in events:
+ if event_type is not None and not event_type.providedBy(event):
+ continue
+ if filter is not None and not filter(event):
+ continue
+ r.append(event)
+
+ return r
+
+def clearEvents():
+ del events[:]
+cleanup.addCleanUp(clearEvents)
+
+class PlacelessSetup:
+
+ def setUp(self):
+ provideHandler(objectEventNotify)
+ provideHandler(dispatchUtilityRegistrationEvent)
+ provideHandler(dispatchAdapterRegistrationEvent)
+ provideHandler(dispatchSubscriptionAdapterRegistrationEvent)
+ provideHandler(dispatchHandlerRegistrationEvent)
+ provideHandler(events.append, (None,))
+
+def setUp(test=None):
+ PlacelessSetup().setUp()
Property changes on: Zope3/branches/jim-adapter/src/zope/component/eventtesting.py
___________________________________________________________________
Name: svn:keywords
+ Id
Name: svn:eol-style
+ native
Modified: Zope3/branches/jim-adapter/src/zope/component/testing.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/testing.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/component/testing.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -15,42 +15,13 @@
$Id$
"""
-from zope.component import provideHandler
-from zope.component.event import objectEventNotify
-from zope.component.registry import dispatchUtilityRegistrationEvent
-from zope.component.registry import dispatchAdapterRegistrationEvent
-from zope.component.registry import (
- dispatchSubscriptionAdapterRegistrationEvent)
-from zope.component.registry import dispatchHandlerRegistrationEvent
-from zope.testing import cleanup
-events = []
-def getEvents(event_type=None, filter=None):
- r = []
- for event in events:
- if event_type is not None and not event_type.providedBy(event):
- continue
- if filter is not None and not filter(event):
- continue
- r.append(event)
+# HACK to make sure basicmost event subscriber is installed
+import zope.component.event
- return r
+# we really don't need special setup now:
+from zope.testing.cleanup import CleanUp as PlacelessSetup
-def clearEvents():
- del events[:]
-cleanup.addCleanUp(clearEvents)
-
-class PlacelessSetup(cleanup.CleanUp):
-
- def setUp(self):
- super(PlacelessSetup, self).setUp()
- provideHandler(events.append, (None,))
- provideHandler(objectEventNotify)
- provideHandler(dispatchUtilityRegistrationEvent)
- provideHandler(dispatchAdapterRegistrationEvent)
- provideHandler(dispatchSubscriptionAdapterRegistrationEvent)
- provideHandler(dispatchHandlerRegistrationEvent)
-
def setUp(test=None):
PlacelessSetup().setUp()
Modified: Zope3/branches/jim-adapter/src/zope/component/tests.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/tests.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/component/tests.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -27,6 +27,10 @@
from zope.component.interfaces import IComponentLookup
from zope.component.testing import setUp, tearDown
+# side effect gets component-based event dispatcher installed.
+# we should obviously make this more explicit
+import zope.component.event
+
import zope.deferredimport
zope.deferredimport.deprecated(
"Use zope.component.testing.placelesssetup",
Modified: Zope3/branches/jim-adapter/src/zope/copypastemove/tests/test_rename.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/copypastemove/tests/test_rename.py 2006-04-26 18:49:36 UTC (rev 67627)
+++ Zope3/branches/jim-adapter/src/zope/copypastemove/tests/test_rename.py 2006-04-26 22:28:30 UTC (rev 67628)
@@ -18,19 +18,20 @@
import unittest
from zope.testing.doctestunit import DocTestSuite
-from zope.component.testing import setUp as setUpCA, tearDown as tearDownCA
+from zope.component import testing, eventtesting
from zope.app.container.tests.placelesssetup import PlacelessSetup
container_setup = PlacelessSetup()
def setUp(test):
- setUpCA()
+ testing.setUp()
+ eventtesting.setUp()
container_setup.setUp()
def test_suite():
return unittest.TestSuite((
DocTestSuite('zope.copypastemove',
- setUp=setUp, tearDown=tearDownCA),
+ setUp=setUp, tearDown=testing.tearDown),
))
if __name__=='__main__':
More information about the Zope3-Checkins
mailing list