[Zope3-checkins] CVS: ZODB4/ZODB - Connection.py:1.79

Jeremy Hylton jeremy@zope.com
Thu, 19 Sep 2002 15:11:33 -0400


Update of /cvs-repository/ZODB4/ZODB
In directory cvs.zope.org:/tmp/cvs-serv27925/ZODB

Modified Files:
	Connection.py 
Log Message:
Change root() to use an explicit __setitem__().

Add comment about keeping a reference to the root.


=== ZODB4/ZODB/Connection.py 1.78 => 1.79 ===
--- ZODB4/ZODB/Connection.py:1.78	Thu Sep 19 14:22:04 2002
+++ ZODB4/ZODB/Connection.py	Thu Sep 19 15:11:32 2002
@@ -117,7 +117,7 @@
             return self._version
 
     def root(self):
-        return self['\0\0\0\0\0\0\0\0']
+        return self.__getitem__('\0\0\0\0\0\0\0\0')
 
     def __getitem__(self, oid):
         # assume that a cache cannot store None as a valid object
@@ -135,8 +135,10 @@
 
         self._cache[oid] = object
         if oid == '\0\0\0\0\0\0\0\0':
-            # XXX Why do we need to keep a ref?
-            self._root = object # keep a ref
+            # Keep a reference to the root so that the pickle cache
+            # won't evict it.  XXX Not sure if this is necessary.  If
+            # the cache is LRU, it should know best if the root is needed.
+            self._root = object
         return object
 
     ######################################################################