[Zope3-checkins] CVS: Zope3/src/zope/app/services - interface.py:1.14.2.1 utility.py:1.14.2.1

Sidnei da Silva sidnei at x3ng.com.br
Tue Aug 12 10:19:59 EDT 2003


Update of /cvs-repository/Zope3/src/zope/app/services
In directory cvs.zope.org:/tmp/cvs-serv22953/src/zope/app/services

Modified Files:
      Tag: dreamcatcher-ttwschema-branch
	interface.py utility.py 
Log Message:
TTWSchema: Work in progress. Made a branch so I can work without disturbing everyone else

=== Zope3/src/zope/app/services/interface.py 1.14 => 1.14.2.1 ===
--- Zope3/src/zope/app/services/interface.py:1.14	Sat Aug  9 14:09:32 2003
+++ Zope3/src/zope/app/services/interface.py	Tue Aug 12 09:19:23 2003
@@ -76,10 +76,9 @@
         next = getNextService(self, Interfaces)
         iface = next.queryInterface(id, default)
         if iface is default:
-            utility_service = getService(self, Utilities)
-            utility = utility_service.queryUtility(IInterface, name=id)
-            if utility is not None:
-                return utility
+            utilities = self._queryUtilityInterfaces(search_string=id)
+            if utilities:
+                return utilities[0][1]
             return default
         return iface
 
@@ -112,12 +111,11 @@
         for item in next.items(search_string, base):
             items[item] = None
         for item in self._queryUtilityInterfaces(base, search_string):
-            items[item] = item
+            if not items.has_key(item):
+                items[item] = None
         return items.keys()
 
     def _queryUtilityInterfaces(self, interface=None, search_string=None):
-        if interface is None:
-            interface = IInterface
         utilities = getService(self, Utilities)
         matching = utilities.getUtilitiesFor(interface)
         matching = [m for m in matching


=== Zope3/src/zope/app/services/utility.py 1.14 => 1.14.2.1 ===
--- Zope3/src/zope/app/services/utility.py:1.14	Thu Aug  7 11:29:48 2003
+++ Zope3/src/zope/app/services/utility.py	Tue Aug 12 09:19:23 2003
@@ -31,6 +31,7 @@
 from zope.interface.implementor import ImplementorRegistry
 from zope.context import ContextMethod
 from zope.app.context import ContextWrapper
+from zope.proxy import removeAllProxies
 
 class LocalUtilityService(Persistent):
 
@@ -114,10 +115,11 @@
             for iface, cr in self._utilities[name].getRegisteredMatching():
                 if not cr:
                     continue
-                if interface and not iface is interface:
-                    continue
                 cr = ContextWrapper(cr, self)
                 utility = cr.active().getComponent()
+                if interface and not iface.extends(interface, 0) and \
+                       removeAllProxies(utility) is not interface:
+                    continue
                 utilities[(name, utility)] = None
 
         next = getNextService(self, "Utilities")
@@ -126,6 +128,7 @@
             if not utilities.has_key(utility):
                 utilities[utility] = None
         return utilities.keys()
+    
     getUtilitiesFor = ContextMethod(getUtilitiesFor)
 
 class UtilityRegistration(ComponentRegistration):




More information about the Zope3-Checkins mailing list