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
_______________________________________________
Zope-Dev maillist  -  Zope-Dev@zope.org
http://mail.zope.org/mailman/listinfo/zope-dev
**  No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope )

Reply via email to