[Zodb-checkins] CVS: Zope3/lib/python/Persistence - Cache.py:1.1.2.5

Jeremy Hylton jeremy@zope.com
Mon, 11 Mar 2002 23:33:46 -0500


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

Modified Files:
      Tag: Zope-3x-branch
	Cache.py 
Log Message:
Add an __delitem__ implementation to the Cache.


=== Zope3/lib/python/Persistence/Cache.py 1.1.2.4 => 1.1.2.5 ===
             self.__active[oid] = ref(object, _dictdel(oid, self.__active))
 
+    def __delitem__(self, oid):
+        # XXX is there any way to know which dict the key is in?
+        try:
+            del self.__ghosts[oid]
+        except KeyError:
+            pass
+        try:
+            del self.__active[oid]
+        except KeyError:
+            pass
+
     def __len__(self):
         return len(self.__ghosts)+len(self.__active)
 
     def setstate(self, oid, object):
-        try: del self.__ghosts[oid]
-        except KeyError: pass
+        try:
+            del self.__ghosts[oid]
+        except KeyError:
+            pass
         self.__active[oid] = ref(object, _dictdel(oid, self.__active))
 
     def incrgc(self, multiple=1):