[Zope-CVS] CVS: Products/Transience - Transience.py:1.17

Matthew T. Kromer matt@zope.com
Thu, 8 Nov 2001 17:05:31 -0500


Update of /cvs-repository/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv11994/lib/python/Products/Transience

Modified Files:
	Transience.py 
Log Message:
Work around a case where has_key and the test suite get into an argument
by checking that the result is a TransientObject before checking if it is
valid.


=== Products/Transience/Transience.py 1.16 => 1.17 ===
 import sys
 import random
+from types import InstanceType
 
 _notfound = []
 _marker = []
@@ -519,7 +520,10 @@
     security.declareProtected(ACCESS_TRANSIENTS_PERM, 'has_key')
     def has_key(self, k):
         v = self.get(k, _notfound) 
-        if v is _notfound or not v.isValid(): return 0
+        if v is _notfound: return 0
+        # Grr, test suite uses ints all over the place
+        if (type(v) is InstanceType and issubclass(v.__class__, TransientObject)
+            and not v.isValid()): return 0
         return 1
 
     def values(self):