[Zope3-checkins]
SVN: Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py
Use newer apis to get registrations.
Jim Fulton
jim at zope.com
Sun Apr 2 17:37:48 EDT 2006
Log message for revision 66330:
Use newer apis to get registrations.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py 2006-04-02 21:37:46 UTC (rev 66329)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py 2006-04-02 21:37:48 UTC (rev 66330)
@@ -45,26 +45,23 @@
def getRequiredAdapters(iface, withViews=False):
"""Get adapter registrations where the specified interface is required."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
- # Only get adapters
- if not isinstance(reg, (AdapterRegistration,
- SubscriptionRegistration,
- HandlerRegistration),
- ):
- continue
- # Ignore adapters that have no required interfaces
- if len(reg.required) == 0:
- continue
- # Ignore views
- if not withViews and reg.required[-1] and \
- reg.required[-1].isOrExtends(IRequest):
- continue
- # Only get the adapters for which this interface is required
- for required_iface in reg.required:
- if iface.isOrExtends(required_iface):
- yield reg
+ for meth in ('registeredAdapters',
+ 'registeredSubscriptionAdapters',
+ 'registeredHandlers'):
+ for reg in getattr(gsm, meth)():
+ # Ignore adapters that have no required interfaces
+ if len(reg.required) == 0:
+ continue
+ # Ignore views
+ if not withViews and reg.required[-1].isOrExtends(IRequest):
+ continue
+ # Only get the adapters for which this interface is required
+ for required_iface in reg.required:
+ if iface.isOrExtends(required_iface):
+ yield reg
+
def getProvidedAdapters(iface, withViews=False):
"""Get adapter registrations where this interface is provided."""
gsm = zapi.getGlobalSiteManager()
More information about the Zope3-Checkins
mailing list