[Zope3-checkins] SVN: Zope3/branches/jim-adapter/src/zope/app/ap
Use newer registration APIs.
Jim Fulton
jim at zope.com
Fri Apr 21 07:49:07 EDT 2006
Log message for revision 67203:
Use newer registration APIs.
Changed:
U Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py
U Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py
U Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py
U Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py
U Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py
-=-
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py 2006-04-21 10:25:35 UTC (rev 67202)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/component.py 2006-04-21 11:49:07 UTC (rev 67203)
@@ -61,14 +61,19 @@
if iface.isOrExtends(required_iface):
yield reg
+def _adapterishRegistrations(registry):
+ for r in registry.registeredAdapters():
+ yield r
+ for r in registry.registeredSubscriptionAdapters():
+ yield r
+ for r in registry.registeredHandlers():
+ yield r
def getProvidedAdapters(iface, withViews=False):
"""Get adapter registrations where this interface is provided."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
+ for reg in _adapterishRegistrations(gsm):
# Only get adapters
- if not isinstance(reg, (AdapterRegistration, SubscriptionRegistration)):
- continue
# Ignore adapters that have no required interfaces
if len(reg.required) == 0:
continue
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py 2006-04-21 10:25:35 UTC (rev 67202)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/presentation.py 2006-04-21 11:49:07 UTC (rev 67203)
@@ -121,9 +121,8 @@
def getViews(iface, type=IRequest):
"""Get all view registrations for a particular interface."""
gsm = zapi.getGlobalSiteManager()
- for reg in gsm.registrations():
- if (isinstance(reg, AdapterRegistration) and
- len(reg.required) > 0 and
+ for reg in gsm.registeredAdapters():
+ if (len(reg.required) > 0 and
reg.required[-1] is not None and
reg.required[-1].isOrExtends(type)):
Modified: Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py 2006-04-21 10:25:35 UTC (rev 67202)
+++ Zope3/branches/jim-adapter/src/zope/app/apidoc/utilitymodule/utilitymodule.py 2006-04-21 11:49:07 UTC (rev 67203)
@@ -123,10 +123,9 @@
sm = zope.component.getSiteManager()
ifaces = {}
while sm is not None:
- for reg in sm.registrations():
- if isinstance(reg, UtilityRegistration):
- path = getPythonPath(reg.provided)
- ifaces[path] = UtilityInterface(self, path, reg.provided)
+ for reg in sm.registeredUtilities():
+ path = getPythonPath(reg.provided)
+ ifaces[path] = UtilityInterface(self, path, reg.provided)
sm = queryNextSiteManager(sm)
items = ifaces.items()
Modified: Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py 2006-04-21 10:25:35 UTC (rev 67202)
+++ Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/browser/tests/test_servercontrolview.py 2006-04-21 11:49:07 UTC (rev 67203)
@@ -46,7 +46,7 @@
def test_ServerControlView(self):
control = ServerControlStub()
- zapi.getGlobalSiteManager().provideUtility(IServerControl, control)
+ zapi.getGlobalSiteManager().registerUtility(control, IServerControl)
test_serverctrl = self._TestView__newView(
applicationController,
Modified: Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py
===================================================================
--- Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py 2006-04-21 10:25:35 UTC (rev 67202)
+++ Zope3/branches/jim-adapter/src/zope/app/applicationcontrol/tests/test_runtimeinfo.py 2006-04-21 11:49:07 UTC (rev 67203)
@@ -80,9 +80,9 @@
# we expect that there is no utility
self.assertEqual(runtime_info.getZopeVersion(), u"Unavailable")
- zapi.getSiteManager().provideUtility(IZopeVersion, TestZopeVersion())
- self.assertEqual(runtime_info.getZopeVersion(),
- stupid_version_string)
+ zapi.getSiteManager().registerUtility(TestZopeVersion(), IZopeVersion)
+ self.assertEqual(runtime_info.getZopeVersion(), stupid_version_string)
+
def test_PythonVersion(self):
runtime_info = self._Test__new()
enc = self._getPreferredEncoding()
More information about the Zope3-Checkins
mailing list