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

Matthew T. Kromer matt@zope.com
Thu, 8 Nov 2001 16:15:29 -0500


Update of /cvs-repository/Products/Transience
In directory cvs.zope.org:/tmp/cvs-serv26481

Modified Files:
	Transience.py 
Log Message:
Add isValid test to has_key.


=== Products/Transience/Transience.py 1.14 => 1.15 ===
         if type(key) is not type(''):
             raise TypeError, (key, "key is not a string type")
-        if self.has_key(key):
+        if self.get(key,None) is not None:
             if self[key].isValid():
                 raise KeyError, key         # Not allowed to dup keys
             del self[key]      
@@ -520,7 +520,9 @@
     def has_key(self, k):
         self._getCurrentBucket()
         index = self._ring._index
-        return index.get(k, _notfound) is not _notfound
+        v = index.get(k, _notfound) 
+        if v is _notfound or not v.isValid(): return 0
+        return 1
 
     def values(self):
         return map(lambda k, self=self: self[k], self.keys())