[Zope-Checkins] CVS: Zope/lib/python/Products/Transience - Transience.py:1.28.4.2

Chris McDonough chrism@zope.com
Sun, 24 Nov 2002 19:15:31 -0500


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

Modified Files:
      Tag: chrism-install-branch
	Transience.py 
Log Message:
Merge with HEAD.


=== Zope/lib/python/Products/Transience/Transience.py 1.28.4.1 => 1.28.4.2 ===
--- Zope/lib/python/Products/Transience/Transience.py:1.28.4.1	Sat Oct 26 15:51:44 2002
+++ Zope/lib/python/Products/Transience/Transience.py	Sun Nov 24 19:14:58 2002
@@ -829,10 +829,46 @@
         return 1
 
     def values(self):
-        return map(lambda k, self=self: self[k], self.keys())
+        # sloppy and loving it!
+        # we used to use something like:
+        # [ self[x] for x in self.keys() ]
+        # but it was causing KeyErrors in getitem's "v = self._data[b][k]"
+        # due to some synchronization problem that I don't understand.
+        # since this is a utility method, I don't care too much. -cm
+        l = []
+        notfound = []
+        for k, t in self._index.items():
+            bucket = self._data.get(t, notfound)
+            if bucket is notfound:
+                continue
+            value = bucket.get(k, notfound)
+            if value is notfound:
+                continue
+            if hasattr(value, '__of__'):
+                value = value.__of__(self)
+            l.append(value)
+        return l
 
     def items(self):
-        return map(lambda k, self=self: (k, self[k]), self.keys())
+        # sloppy and loving it!
+        # we used to use something like:
+        # [ (x, self[x]) for x in self.keys() ]
+        # but it was causing KeyErrors in getitem's "v = self._data[b][k]"
+        # due to some synchronization problem that I don't understand.
+        # since this is a utility method, I don't care too much. -cm
+        l = []
+        notfound = []
+        for k, t in self._index.items():
+            bucket = self._data.get(t, notfound)
+            if bucket is notfound:
+                continue
+            value = bucket.get(k, notfound)
+            if value is notfound:
+                continue
+            if hasattr(value, '__of__'):
+                value = value.__of__(self)
+            l.append((k, value))
+        return l
 
     def true_items(self):
         l = []