[Zodb-checkins] CVS: Zope3/lib/python/ZODB - Connection.py:1.60.6.7

Jeremy Hylton jeremy@zope.com
Fri, 8 Mar 2002 20:24:33 -0500


Update of /cvs-repository/Zope3/lib/python/ZODB
In directory cvs.zope.org:/tmp/cvs-serv6431

Modified Files:
      Tag: Zope-3x-branch
	Connection.py 
Log Message:
Fix major bug in new invalidation code.

The new ICache interface has different semantics for invalidateMany()
than the ZODB 3 cPickleCache.  In particular, it acceptables a
sequence of oids, or, more specifically (and harder to say intelligably)
an iterable object of oids.  It is the _client's_ responsibility to
reset this sequence after calling invalidateMnay.  

The cPickleCache invalidateMany() accepted a dictionary and called its
clear method before returning.  The Connection in Zope3 still relied
on this behavior, which meant that the invalidation dict was never
cleared!

The only tests that exercise this feature are the MTStorage tests that
I will check in shortly.


=== Zope3/lib/python/ZODB/Connection.py 1.60.6.6 => 1.60.6.7 ===
             self._resetCache()
         else:
-            self._cache.invalidateMany(self._invalidated)
+            self._cache.invalidateMany(self._invalidated.iterkeys())
+            self._invalidated.clear()
         self._opened=time()
 
         return self
@@ -264,7 +265,8 @@
         This just deactivates the thing.
         """
         if object is self:
-            self._cache.invalidateMany(self._invalidated)
+            self._cache.invalidateMany(self._invalidated.iterkeys())
+            self._invalidated.clear()
         else:
             self._cache.invalidate(object._p_oid)
 
@@ -446,8 +448,8 @@
         self._tmp=None
         self._storage=tmp
 
-        
-        self._cache.invalidateMany(src._index.keys())
+        self._cache.invalidateMany(src._index.iterkeys())
+        src._index.clear()
         self._invalidate_creating(src._creating)
 
     def _invalidate_creating(self, creating=None):
@@ -539,8 +541,10 @@
         if self.__onCommitActions is not None:
             del self.__onCommitActions
         self._storage.tpc_abort(transaction)
-        self._cache.invalidateMany(self._invalidated)
-        self._cache.invalidateMany(self._invalidating)
+        self._cache.invalidateMany(self._invalidated.iterkeys())
+        self._invalidated.clear()
+        self._cache.invalidateMany(self._invalidating.iterkeys())
+        self._invalidatng.clear()
         self._invalidate_creating()
 
     def tpc_begin(self, transaction, sub=None):
@@ -632,7 +636,8 @@
             self._storage.tpc_finish(transaction,
                                      self._invalidate_invalidating)
 
-        self._cache.invalidateMany(self._invalidated)
+        self._cache.invalidateMany(self._invalidated.iterkeys())
+        self._invalidated.clear()
         self._incrgc() # This is a good time to do some GC
 
     def _invalidate_invalidating(self):
@@ -645,7 +650,8 @@
         get_transaction().abort()
         sync=getattr(self._storage, 'sync', 0)
         if sync != 0: sync()
-        self._cache.invalidateMany(self._invalidated)
+        self._cache.invalidateMany(self._invalidated.iterkeys())
+        self._invalidated.clear()
         self._incrgc() # This is a good time to do some GC
 
     def getDebugInfo(self): return self._debug_info