[Zope3-checkins] CVS: Zope3/src/zope/app/browser/services - view.py:1.11

Guido van Rossum guido@python.org
Thu, 1 May 2003 10:40:25 -0400


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

Modified Files:
	view.py 
Log Message:
In _getInfosFromKey(), we must be careful to only return those matches
from getRegisteredMatching() that match the specified interface
exactly.  The way getRegisteredMatching() is written, it can returns
other matches too: when requesting an interface I2 which is derived
from I1, asking for I2 will also return matches using I1; in addition,
when the interface name is "(Anything)", we set forInterface to None,
which is interpreted as a wildcard search.  Note that we must use '=='
for the comparison, not 'is', because there may be proxies.


=== Zope3/src/zope/app/browser/services/view.py 1.10 => 1.11 ===
--- Zope3/src/zope/app/browser/services/view.py:1.10	Wed Apr 30 18:06:31 2003
+++ Zope3/src/zope/app/browser/services/view.py	Thu May  1 10:40:24 2003
@@ -102,10 +102,12 @@
         else:
             forInterface = sm.resolve(forInterfaceName)
         presentationType = sm.resolve(presentationTypeName)
-        return self.context.getRegisteredMatching(forInterface,
-                                                  presentationType,
-                                                  viewName,
-                                                  layerName)
+        infos = self.context.getRegisteredMatching(forInterface,
+                                                   presentationType,
+                                                   viewName,
+                                                   layerName)
+        # We only want exact matches on 'forInterface'
+        return [info for info in infos if info[0] == forInterface]
 
     def _deactivate(self, todo):
         done = []