[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/traversing/adapters.py Now raising TraversalError if __getitem__ fails with KeyError.

Garrett Smith garrett at mojave-corp.com
Wed Mar 9 13:50:52 EST 2005


Log message for revision 29426:
  Now raising TraversalError if __getitem__ fails with KeyError.

Changed:
  U   Zope3/trunk/src/zope/app/traversing/adapters.py

-=-
Modified: Zope3/trunk/src/zope/app/traversing/adapters.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/adapters.py	2005-03-09 18:45:51 UTC (rev 29425)
+++ Zope3/trunk/src/zope/app/traversing/adapters.py	2005-03-09 18:50:51 UTC (rev 29426)
@@ -48,13 +48,14 @@
         attr = getattr(subject, name, _marker)
         if attr is not _marker:
             return attr
-
         if hasattr(subject, '__getitem__'):
-            # Let exceptions propagate.
-            return subject[name]
-        else:
-            raise TraversalError(subject, name)
+            try:
+                return subject[name]
+            except KeyError:
+                pass
+        raise TraversalError(subject, name)
 
+
 class RootPhysicallyLocatable(object):
     __doc__ = IPhysicallyLocatable.__doc__
 



More information about the Zope3-Checkins mailing list