[Zope-Checkins] CVS: ZODB3/ZODB - FileStorage.py:1.115

Jeremy Hylton jeremy@zope.com
Mon, 18 Nov 2002 15:44:30 -0500


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv4763/ZODB

Modified Files:
	FileStorage.py 
Log Message:
A little cleanup and an added comment.


=== ZODB3/ZODB/FileStorage.py 1.114 => 1.115 ===
--- ZODB3/ZODB/FileStorage.py:1.114	Tue Nov  5 16:49:50 2002
+++ ZODB3/ZODB/FileStorage.py	Mon Nov 18 15:44:30 2002
@@ -285,6 +285,10 @@
                 read_only=read_only,
                 )
         self._ltid = tid
+        
+        # self._pos should always point just past the last
+        # transaction.  During 2PC, data is written after _pos.
+        # invariant is restored at tpc_abort() or tpc_finish().
 
         self._ts = tid = TimeStamp(tid)
         t = time.time()
@@ -402,15 +406,12 @@
             return ltid
 
     def _restore_index(self):
-        """Load the database index from a file to support quick startup
-        """
-        file_name=self.__name__
-        index_name=file_name+'.index'
-
-        try: f=open(index_name,'rb')
-        except: return None
-
-        p=Unpickler(f)
+        """Load database index to support quick startup."""
+        try:
+            f = open("%s.index" % self.__name__, 'rb')
+        except:
+            return None
+        p = Unpickler(f)
 
         try:
             info=p.load()
@@ -419,16 +420,17 @@
             warn("Failed to load database index: %s: %s" %
                  (exc, err))
             return None
-        index=info.get('index')
-        pos=info.get('pos')
-        oid=info.get('oid')
-        vindex=info.get('vindex')
+        index = info.get('index')
+        pos = info.get('pos')
+        oid = info.get('oid')
+        vindex = info.get('vindex')
         if index is None or pos is None or oid is None or vindex is None:
             return None
         pos = long(pos)
 
-        tid=self._sane(index, pos)
-        if not tid: return None
+        tid = self._sane(index, pos)
+        if not tid:
+            return None
 
         return index, vindex, pos, oid, tid