[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/ Arranged, for now,
that component-registration events are suppressed
Jim Fulton
jim at zope.com
Wed Apr 26 14:49:28 EDT 2006
Log message for revision 67624:
Arranged, for now, that component-registration events are suppressed
when the convenience-registration routines are used. This is to
prevent test failures in tests that log all events.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/testing/ztapi.py
U Zope3/branches/jim-adapter/src/zope/component/globalregistry.py
U Zope3/branches/jim-adapter/src/zope/component/registry.py
U Zope3/branches/jim-adapter/src/zope/component/registry.txt
U Zope3/branches/jim-adapter/src/zope/wfmc/README.txt
U Zope3/branches/jim-adapter/src/zope/wfmc/xpdl.txt
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/testing/ztapi.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/testing/ztapi.py 2006-04-26 18:49:25 UTC (rev 67623)
+++ Zope3/branches/jim-adapter/src/zope/app/testing/ztapi.py 2006-04-26 18:49:27 UTC (rev 67624)
@@ -72,19 +72,20 @@
elif not isinstance(required, stypes):
required = (required,)
- gsm.registerAdapter(factory, required, provided, name)
+ gsm.registerAdapter(factory, required, provided, name, event=False)
def subscribe(required, provided, factory):
gsm = zope.component.getGlobalSiteManager()
if provided is None:
- gsm.registerHandler(factory, required)
+ gsm.registerHandler(factory, required, event=False)
else:
- gsm.registerSubscriptionAdapter(factory, required, provided)
+ gsm.registerSubscriptionAdapter(factory, required, provided,
+ event=False)
def provideUtility(provided, component, name=''):
gsm = zope.component.getGlobalSiteManager()
- gsm.registerUtility(component, provided, name)
+ gsm.registerUtility(component, provided, name, event=False)
def unprovideUtility(provided, name=''):
gsm = zope.component.getGlobalSiteManager()
Modified: Zope3/branches/jim-adapter/src/zope/component/globalregistry.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/globalregistry.py 2006-04-26 18:49:25 UTC (rev 67623)
+++ Zope3/branches/jim-adapter/src/zope/component/globalregistry.py 2006-04-26 18:49:27 UTC (rev 67624)
@@ -158,14 +158,14 @@
provideHandler = base.registerHandler
def provideUtility(component, provides=None, name=u''):
- base.registerUtility(component, provides, name)
+ base.registerUtility(component, provides, name, event=False)
def provideAdapter(factory, adapts=None, provides=None, name=''):
- base.registerAdapter(factory, adapts, provides, name)
+ base.registerAdapter(factory, adapts, provides, name, event=False)
def provideSubscriptionAdapter(factory, adapts=None, provides=None):
- base.registerSubscriptionAdapter(factory, adapts, provides)
+ base.registerSubscriptionAdapter(factory, adapts, provides, event=False)
def provideHandler(factory, adapts=None):
- base.registerHandler(factory, adapts)
+ base.registerHandler(factory, adapts, event=False)
Modified: Zope3/branches/jim-adapter/src/zope/component/registry.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/registry.py 2006-04-26 18:49:25 UTC (rev 67623)
+++ Zope3/branches/jim-adapter/src/zope/component/registry.py 2006-04-26 18:49:27 UTC (rev 67624)
@@ -65,7 +65,8 @@
lambda self, bases: self._setBases(bases),
)
- def registerUtility(self, component, provided=None, name=u'', info=u''):
+ def registerUtility(self, component, provided=None, name=u'', info=u'',
+ event=True):
if provided is None:
provided = _getUtilityProvided(component)
@@ -86,9 +87,10 @@
if not subscribed:
self.utilities.subscribe((), provided, component)
- zope.event.notify(interfaces.Registered(
- UtilityRegistration(self, provided, name, component, info)
- ))
+ if event:
+ zope.event.notify(interfaces.Registered(
+ UtilityRegistration(self, provided, name, component, info)
+ ))
def unregisterUtility(self, component=None, provided=None, name=u''):
if provided is None:
@@ -145,20 +147,21 @@
return self.utilities.subscriptions((), interface)
def registerAdapter(self, factory, required=None, provided=None, name=u'',
- info=u''):
+ info=u'', event=True):
if provided is None:
provided = _getAdapterProvided(factory)
required = _getAdapterRequired(factory, required)
self._adapter_registrations[(required, provided, name)
] = factory, info
self.adapters.register(required, provided, name, factory)
-
- zope.event.notify(interfaces.Registered(
- AdapterRegistration(self, required, provided, name,
- factory, info)
- ))
+ if event:
+ zope.event.notify(interfaces.Registered(
+ AdapterRegistration(self, required, provided, name,
+ factory, info)
+ ))
+
def unregisterAdapter(self, factory=None,
required=None, provided=None, name=u'',
):
@@ -221,7 +224,8 @@
def registerSubscriptionAdapter(self,
factory, required=None, provided=None,
- name=u'', info=u''):
+ name=u'', info=u'',
+ event=True):
if name:
raise TypeError("Named subscribers are not yet supported")
if provided is None:
@@ -231,12 +235,13 @@
(required, provided, name, factory, info)
)
self.adapters.subscribe(required, provided, factory)
-
- zope.event.notify(interfaces.Registered(
- SubscriptionRegistration(self, required, provided, name,
- factory, info)
- ))
+ if event:
+ zope.event.notify(interfaces.Registered(
+ SubscriptionRegistration(self, required, provided, name,
+ factory, info)
+ ))
+
def registeredSubscriptionAdapters(self):
for data in self._subscription_registrations:
yield SubscriptionRegistration(self, *data)
@@ -288,7 +293,8 @@
def registerHandler(self,
factory, required=None,
- name=u'', info=u''):
+ name=u'', info=u'',
+ event=True):
if name:
raise TypeError("Named handlers are not yet supported")
required = _getAdapterRequired(factory, required)
@@ -297,9 +303,10 @@
)
self.adapters.subscribe(required, None, factory)
- zope.event.notify(interfaces.Registered(
- HandlerRegistration(self, required, name, factory, info)
- ))
+ if event:
+ zope.event.notify(interfaces.Registered(
+ HandlerRegistration(self, required, name, factory, info)
+ ))
def registeredHandlers(self):
for data in self._handler_registrations:
@@ -332,7 +339,7 @@
self._handler_registrations[:] = new
self.adapters.unsubscribe(required, None)
-
+
zope.event.notify(interfaces.Unregistered(
HandlerRegistration(self, required, name, factory, '')
))
Modified: Zope3/branches/jim-adapter/src/zope/component/registry.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/component/registry.txt 2006-04-26 18:49:25 UTC (rev 67623)
+++ Zope3/branches/jim-adapter/src/zope/component/registry.txt 2006-04-26 18:49:27 UTC (rev 67624)
@@ -936,7 +936,8 @@
>>> from zope import component
>>> import zope.component.event
- >>> zope.component.provideHandler(zope.component.event.objectEventNotify)
+ >>> zope.component.getGlobalSiteManager().registerHandler(
+ ... zope.component.event.objectEventNotify)
... # doctest: +NORMALIZE_WHITESPACE
Registered event:
HandlerRegistration(<BaseGlobalComponents base>,
@@ -950,7 +951,7 @@
... print 'Double dispatch:'
... print ' ', o1
... print ' ', o2
- >>> zope.component.provideHandler(double_handler)
+ >>> zope.component.getGlobalSiteManager().registerHandler(double_handler)
... # doctest: +NORMALIZE_WHITESPACE
Double dispatch:
HandlerRegistration(<BaseGlobalComponents base>,
@@ -966,25 +967,25 @@
Now we'll register our handlers:
- >>> zope.component.provideHandler(
+ >>> zope.component.getGlobalSiteManager().registerHandler(
... registry.dispatchUtilityRegistrationEvent)
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Double dispatch:
...
- >>> zope.component.provideHandler(
+ >>> zope.component.getGlobalSiteManager().registerHandler(
... registry.dispatchAdapterRegistrationEvent)
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Double dispatch:
...
- >>> zope.component.provideHandler(
+ >>> zope.component.getGlobalSiteManager().registerHandler(
... registry.dispatchSubscriptionAdapterRegistrationEvent)
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Double dispatch:
...
- >>> zope.component.provideHandler(
+ >>> zope.component.getGlobalSiteManager().registerHandler(
... registry.dispatchHandlerRegistrationEvent)
... # doctest: +NORMALIZE_WHITESPACE
Double dispatch:
Modified: Zope3/branches/jim-adapter/src/zope/wfmc/README.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/wfmc/README.txt 2006-04-26 18:49:25 UTC (rev 67623)
+++ Zope3/branches/jim-adapter/src/zope/wfmc/README.txt 2006-04-26 18:49:27 UTC (rev 67624)
@@ -102,10 +102,6 @@
>>> pd = process.ProcessDefinition('sample')
>>> zope.component.provideUtility(pd, name=pd.id)
- ... # doctest: +NORMALIZE_WHITESPACE
- Registered event:
- UtilityRegistration(<BaseGlobalComponents base>,
- IProcessDefinition, 'sample', ProcessDefinition('sample'), u'')
>>> pd.defineActivities(
... author = process.ActivityDefinition(),
@@ -341,10 +337,6 @@
>>> pd = process.ProcessDefinition('sample', integration)
>>> zope.component.provideUtility(pd, name=pd.id)
- ... # doctest: +NORMALIZE_WHITESPACE
- Registered event:
- UtilityRegistration(<BaseGlobalComponents base>,
- IProcessDefinition, 'sample', ProcessDefinition('sample'), u'')
>>> pd.defineActivities(
... author = process.ActivityDefinition(),
@@ -418,12 +410,7 @@
>>> pd = process.ProcessDefinition('sample', integration)
>>> zope.component.provideUtility(pd, name=pd.id)
- ... # doctest: +NORMALIZE_WHITESPACE
- Registered event:
- UtilityRegistration(<BaseGlobalComponents base>,
- IProcessDefinition, 'sample', ProcessDefinition('sample'), u'')
-
>>> pd.defineActivities(
... author = process.ActivityDefinition(),
... review = process.ActivityDefinition(),
@@ -582,10 +569,6 @@
>>> Publication = process.ProcessDefinition('Publication')
>>> Publication.integration = integration
>>> zope.component.provideUtility(Publication, name=Publication.id)
- ... # doctest: +NORMALIZE_WHITESPACE
- Registered event:
- UtilityRegistration(<BaseGlobalComponents base>,
- IProcessDefinition, 'Publication', ProcessDefinition('Publication'), u'')
>>> Publication.defineActivities(
... start = process.ActivityDefinition("Start"),
Modified: Zope3/branches/jim-adapter/src/zope/wfmc/xpdl.txt
===================================================================
--- Zope3/branches/jim-adapter/src/zope/wfmc/xpdl.txt 2006-04-26 18:49:25 UTC (rev 67623)
+++ Zope3/branches/jim-adapter/src/zope/wfmc/xpdl.txt 2006-04-26 18:49:27 UTC (rev 67624)
@@ -39,10 +39,6 @@
>>> import zope.component
>>> zope.component.provideUtility(pd, name=pd.id)
- ... # doctest: +NORMALIZE_WHITESPACE
- Registered event:
- UtilityRegistration(<BaseGlobalComponents base>,
- IProcessDefinition, u'Publication', Publication, u'')
and we'll define and register participant and application adapters:
More information about the Zope3-Checkins
mailing list