[Zope3-checkins] CVS: Zope3/src/zope/component - utility.py:1.11
Jim Fulton
jim at zope.com
Mon Apr 12 13:28:56 EDT 2004
Update of /cvs-repository/Zope3/src/zope/component
In directory cvs.zope.org:/tmp/cvs-serv19863/src/zope/component
Modified Files:
utility.py
Log Message:
Simplified/sped up by implementing lookup methods directly.
Also subclasses GlobalService, to facilitate pickling, and thus local
services.
=== Zope3/src/zope/component/utility.py 1.10 => 1.11 ===
--- Zope3/src/zope/component/utility.py:1.10 Sun Apr 11 14:16:43 2004
+++ Zope3/src/zope/component/utility.py Mon Apr 12 13:28:55 2004
@@ -18,6 +18,7 @@
from zope.component.exceptions import Invalid, ComponentLookupError
from zope.component.interfaces import IUtilityService, IComponentRegistry
+from zope.component.service import GlobalService
from zope.interface.adapter import AdapterRegistry
from zope.interface import implements
@@ -29,7 +30,7 @@
A utility is a component that provides an interface.
"""
-class GlobalUtilityService(AdapterRegistry):
+class GlobalUtilityService(AdapterRegistry, GlobalService):
implements(IGlobalUtilityService)
@@ -61,10 +62,17 @@
def queryUtility(self, interface, default=None, name=''):
"""See IUtilityService interface"""
- return self.lookup((), interface, name, default)
+ byname = self._null.get(interface)
+ if byname:
+ return byname.get(name, default)
+ else:
+ return default
def getUtilitiesFor(self, interface):
- return AdapterRegistry.lookupAll(self, (), interface)
+ byname = self._null.get(interface)
+ if byname:
+ for item in byname.iteritems():
+ yield item
def getRegisteredMatching(self, interface=None, name=None):
# doomed method
More information about the Zope3-Checkins
mailing list