[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/app/ Use
newer registration apis.
Jim Fulton
jim at zope.com
Tue Apr 4 07:23:04 EDT 2006
Log message for revision 66381:
Use newer registration apis.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py
U Zope3/branches/jim-adapter/src/zope/app/component/back35.py
U Zope3/branches/jim-adapter/src/zope/app/component/site.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py 2006-04-04 11:23:01 UTC (rev 66380)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py 2006-04-04 11:23:04 UTC (rev 66381)
@@ -73,18 +73,16 @@
if key == NONAME:
key = ''
utils = [Utility(self, reg)
- for reg in sm.registrations()
- if zapi.isinstance(reg, UtilityRegistration) and \
- reg.name == key and reg.provided == self.interface]
+ for reg in sm.registeredUtilities()
+ if reg.name == key and reg.provided == self.interface]
return utils and utils[0] or default
def items(self):
"""See zope.app.container.interfaces.IReadContainer"""
sm = zapi.getGlobalSiteManager()
items = [(encodeName(reg.name or NONAME), Utility(self, reg))
- for reg in sm.registrations()
- if zapi.isinstance(reg, UtilityRegistration) and \
- self.interface == reg.provided]
+ for reg in sm.registeredUtilities()
+ if self.interface == reg.provided]
items.sort()
return items
Modified: Zope3/branches/jim-adapter/src/zope/app/component/back35.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/back35.py 2006-04-04 11:23:01 UTC (rev 66380)
+++ Zope3/branches/jim-adapter/src/zope/app/component/back35.py 2006-04-04 11:23:04 UTC (rev 66381)
@@ -359,16 +359,14 @@
if not registry.registered(registration):
registry.register(registration)
zope.event.notify(
- zope.app.component.registration.RegistrationActivatedEvent(
- registration)
+ zope.component.interfaces.Registered(registration)
)
elif value == interfaces.InactiveStatus:
if registry.registered(registration):
registry.unregister(registration)
zope.event.notify(
- zope.app.component.registration.RegistrationDeactivatedEvent(
- registration)
+ zope.component.interfaces.Unregistered(registration)
)
else:
raise ValueError(value)
Modified: Zope3/branches/jim-adapter/src/zope/app/component/site.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/component/site.py 2006-04-04 11:23:01 UTC (rev 66380)
+++ Zope3/branches/jim-adapter/src/zope/app/component/site.py 2006-04-04 11:23:04 UTC (rev 66381)
@@ -33,6 +33,7 @@
import zope.deferredimport
from zope.component.interfaces import ComponentLookupError
+import zope.component.interfaces
from zope.security.proxy import removeSecurityProxy
from zope.app import zapi
@@ -263,7 +264,8 @@
"defined in zope.component, especially IComponentRegistry.",
)
def registered(self, registration):
- if interfaces.IUtilityRegistration.providedBy(registration):
+ if zope.component.interfaces.IUtilityRegistration.providedBy(
+ registration):
return bool([
r for r in self.registeredUtilities()
if (
@@ -274,11 +276,12 @@
r.name == registration.name
)
])
- elif interfaces.IAdapterRegistration.providedBy(registration):
+ elif zope.component.interfaces.IAdapterRegistration.providedBy(
+ registration):
return bool([
r for r in self.registeredAdapters()
if (
- r.component == registration.component
+ r.factory == registration.component
and
r.provided == registration.provided
and
@@ -288,6 +291,37 @@
+ registration.with)
)
])
+ elif (
+ zope.component.interfaces.ISubscriptionAdapterRegistration.providedBy(
+ registration)):
+ return bool([
+ r for r in self.registeredSubscriptionAdapters()
+ if (
+ r.factory == registration.component
+ and
+ r.provided == registration.provided
+ and
+ r.name == registration.name
+ and
+ r.required == ((registration.required, )
+ + registration.with)
+ )
+ ])
+ elif zope.component.interfaces.IHandlerRegistration.providedBy(
+ registration):
+ return bool([
+ r for r in self.registeredHandlers()
+ if (
+ r.factory == registration.component
+ and
+ r.provided == registration.provided
+ and
+ r.name == registration.name
+ and
+ r.required == ((registration.required, )
+ + registration.with)
+ )
+ ])
return False
def registrations(self):
More information about the Zope3-Checkins
mailing list