Skip to content

Commit

Permalink
Use newer apis to get registrations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Apr 2, 2006
1 parent 23818d6 commit 405ed8e
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions component.py
Expand Up @@ -45,24 +45,21 @@
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):
Expand Down

0 comments on commit 405ed8e

Please sign in to comment.