[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/intid/ getId now raises a KeyError if it encounters a NotYet. Similarly,

Jim Fulton jim at zope.com
Fri May 27 17:25:58 EDT 2005


Log message for revision 30546:
  getId now raises a KeyError if it encounters a NotYet.  Similarly,
  queryId returns the default if it encounters a NotYet exception.
  

Changed:
  U   Zope3/trunk/src/zope/app/intid/__init__.py
  U   Zope3/trunk/src/zope/app/intid/tests.py

-=-
Modified: Zope3/trunk/src/zope/app/intid/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/__init__.py	2005-05-27 21:24:36 UTC (rev 30545)
+++ Zope3/trunk/src/zope/app/intid/__init__.py	2005-05-27 21:25:28 UTC (rev 30546)
@@ -31,7 +31,7 @@
 
 from zope.app import zapi
 from zope.app.container.contained import Contained
-from zope.app.keyreference.interfaces import IKeyReference
+from zope.app.keyreference.interfaces import IKeyReference, NotYet
 from zope.app.location.interfaces import ILocation
 from zope.app.location.interfaces import ITransientLocation
 
@@ -74,8 +74,16 @@
 
     def getId(self, ob):
         if not ITransientLocation.providedBy(ob):
-            ref = IKeyReference(ob)
-            return self.ids[ref]
+            try:
+                ref = IKeyReference(ob)
+            except NotYet:
+                raise KeyError(ob)
+
+            try:
+                return self.ids[ref]
+            except KeyError:
+                raise KeyError(ob)
+
         else:
             raise KeyError(ob)
 

Modified: Zope3/trunk/src/zope/app/intid/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/intid/tests.py	2005-05-27 21:24:36 UTC (rev 30545)
+++ Zope3/trunk/src/zope/app/intid/tests.py	2005-05-27 21:25:28 UTC (rev 30546)
@@ -80,10 +80,12 @@
 
         self.assertRaises(KeyError, u.getId, obj)
         self.assertRaises(KeyError, u.getId, t_obj)
+        self.assertRaises(KeyError, u.getId, P())
         self.assertRaises(TypeError, u.getId, object())
 
         self.assert_(u.queryId(obj) is None)
         self.assert_(u.queryId(obj, 42) is 42)
+        self.assert_(u.queryId(P(), 42) is 42)
         self.assert_(u.queryId(t_obj) is None)
         self.assertRaises(TypeError, u.queryId, object())
         self.assert_(u.queryObject(42) is None)



More information about the Zope3-Checkins mailing list