Here's a little patch that eliminates some duplication in getRequiredAdapters(). It changes it to use the _adapterishRegistrations() utility function, as getProvidedAdapters() does, rather than repeating the ('registeredAdapters', 'registeredSubscriptionAdapters', 'registeredHandlers') triad. --- src/zope/app/apidoc/component.py (revision 80884) +++ src/zope/app/apidoc/component.py (working copy) @@ -45,22 +45,18 @@ def getRequiredAdapters(iface, withViews=False): """Get adapter registrations where the specified interface is required.""" gsm = getGlobalSiteManager() - for meth in ('registeredAdapters', - 'registeredSubscriptionAdapters', - 'registeredHandlers'): + for reg in _adapterishRegistrations(gsm): + # 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 - 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 - Cheers, Erik Rose WebLion Core Developer Pennsylvania State University
Hi, Am Montag, den 15.10.2007, 17:29 -0400 schrieb Erik Rose:
Here's a little patch that eliminates some duplication in getRequiredAdapters(). It changes it to use the _adapterishRegistrations() utility function, as getProvidedAdapters() does, rather than repeating the ('registeredAdapters', 'registeredSubscriptionAdapters', 'registeredHandlers') triad.
I propose to add this patch as a bug in launchpad: https://bugs.edge.launchpad.net/zope3/+filebug Christian -- gocept gmbh & co. kg - forsterstrasse 29 - 06112 halle/saale - germany www.gocept.com - ct@gocept.com - phone +49 345 122 9889 7 - fax +49 345 122 9889 1 - zope and plone consulting and development
I propose to add this patch as a bug in launchpad: https://bugs.edge.launchpad.net/zope3/+filebug
Danke. Done. :-) Erik
participants (2)
-
Christian Theune -
Erik Rose