[Zope3-checkins] CVS: Zope3/src/zope/app/apidoc/ifacemodule -
browser.py:1.8
Stephan Richter
srichter at cosmos.phy.tufts.edu
Wed Apr 7 22:12:27 EDT 2004
Update of /cvs-repository/Zope3/src/zope/app/apidoc/ifacemodule
In directory cvs.zope.org:/tmp/cvs-serv25399/src/zope/app/apidoc/ifacemodule
Modified Files:
browser.py
Log Message:
Make use of new registrations() method for the adapter registry.
=== Zope3/src/zope/app/apidoc/ifacemodule/browser.py 1.7 => 1.8 ===
--- Zope3/src/zope/app/apidoc/ifacemodule/browser.py:1.7 Mon Apr 5 15:44:05 2004
+++ Zope3/src/zope/app/apidoc/ifacemodule/browser.py Wed Apr 7 22:12:25 2004
@@ -336,25 +336,30 @@
>>> pprint(adapters)
[[('factory', 'zope.app.location.LocationPhysicallyLocatable'),
('factory_url', 'zope/app/location/LocationPhysicallyLocatable'),
- ('name', u''),
+ ('name', ''),
('provided',
'zope.app.traversing.interfaces.IPhysicallyLocatable'),
('required', [])]]
"""
service = zapi.getService(self.context, 'Adapters')
- context = removeAllProxies(self.context)
+ iface = removeAllProxies(self.context)
adapters = []
- for adapter in service.getRegisteredMatching(required=context):
- factory = _getRealFactory(adapter[4])
+ for reg in service.registrations():
+ # Only grab the adapters for which this interface is required
+ if reg.required[0] is not None and iface not in reg.required:
+ continue
+ factory = _getRealFactory(reg.value)
path = getPythonPath(factory)
if type(factory) in (FunctionType, MethodType):
url = None
else:
url = path.replace('.', '/')
adapters.append({
- 'provided': getPythonPath(adapter[1]),
- 'required': [getPythonPath(iface) for iface in adapter[2]],
- 'name': adapter[3],
+ 'provided': getPythonPath(reg.provided),
+ 'required': [getPythonPath(iface)
+ for iface in reg.required
+ if iface is not None],
+ 'name': reg.name,
'factory': path,
'factory_url': url
})
@@ -373,23 +378,25 @@
>>> pprint(adapters)
[[('factory', '__builtin__.object'),
('factory_url', '__builtin__/object'),
- ('name', u''),
+ ('name', ''),
('required', ['zope.app.apidoc.ifacemodule.tests.IBar'])]]
"""
service = zapi.getService(self.context, 'Adapters')
- context = removeAllProxies(self.context)
+ iface = removeAllProxies(self.context)
adapters = []
- for adapter in service.getRegisteredMatching(provided=context):
- factory = _getRealFactory(adapter[4])
+ for reg in service.registrations():
+ # Only grab adapters for which this interface is provided
+ if iface is not reg.provided:
+ continue
+ factory = _getRealFactory(reg.value)
path = getPythonPath(factory)
if type(factory) in (FunctionType, MethodType):
url = None
else:
url = path.replace('.', '/')
adapters.append({
- 'required': [getPythonPath(iface)
- for iface in adapter[2]+(adapter[0],)],
- 'name': adapter[3],
+ 'required': [getPythonPath(iface) for iface in reg.required],
+ 'name': reg.name,
'factory': path,
'factory_url': url
})
More information about the Zope3-Checkins
mailing list