[Zope3-checkins] CVS: Zope3/lib/python/ZODB - FileStorage.py:1.110

Jeremy Hylton jeremy@zope.com
Wed, 4 Dec 2002 16:41:36 -0500


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

Modified Files:
	FileStorage.py 
Log Message:
Fix pack().

During the sync operation, it started ignoring its argument.
Also much whitespace normalization.





=== Zope3/lib/python/ZODB/FileStorage.py 1.109 => 1.110 ===
--- Zope3/lib/python/ZODB/FileStorage.py:1.109	Tue Dec  3 18:45:02 2002
+++ Zope3/lib/python/ZODB/FileStorage.py	Wed Dec  4 16:41:36 2002
@@ -136,7 +136,7 @@
 from ZODB import BaseStorage, ConflictResolution, POSException
 from ZODB.POSException import UndoError, POSKeyError, MultipleUndoErrors
 from ZODB.Serialize import findrefs
-from ZODB.TimeStamp import TimeStamp, newTimeStamp
+from ZODB.TimeStamp import TimeStamp, newTimeStamp, timeStampFromTime
 from ZODB.lock_file import lock_file
 from ZODB.utils import p64, u64, cp, z64
 
@@ -564,7 +564,7 @@
     def _loada(self, oid, _index, file):
         "Read any version and return the version"
         try:
-            pos=_index[oid]
+            pos = _index[oid]
         except KeyError:
             raise POSKeyError(oid)
         file.seek(pos)
@@ -962,18 +962,17 @@
             self._lock_release()
 
     def _finish(self, tid, u, d, e):
-        nextpos=self._nextpos
+        nextpos = self._nextpos
         if nextpos:
-            file=self._file
-
             # Clear the checkpoint flag
-            file.seek(self._pos+16)
-            file.write(self._tstatus)
-            file.flush()
+            self._file.seek(self._pos+16)
+            self._file.write(self._tstatus)
+            self._file.flush()
 
-            if fsync is not None: fsync(file.fileno())
+            if fsync is not None:
+                fsync(self._file.fileno())
 
-            self._pos=nextpos
+            self._pos = nextpos
 
             self._index.update(self._tindex)
             self._vindex.update(self._tvindex)
@@ -1053,12 +1052,13 @@
         be 0, but the pickle can be empty *and* the pointer 0.
         """
 
-        copy=1 # Can we just copy a data pointer
+        copy = 1 # Can we just copy a data pointer
 
         # First check if it is possible to undo this record.
-        tpos=self._tindex.get(oid, 0)
-        ipos=self._index.get(oid, 0)
-        tipos=tpos or ipos
+        tpos = self._tindex.get(oid, 0)
+        ipos = self._index.get(oid, 0)
+        tipos = tpos or ipos
+
         if tipos != pos:
             # Eek, a later transaction modified the data, but,
             # maybe it is pointing at the same data we are.
@@ -1107,7 +1107,7 @@
         except KeyError:
             # couldn't find oid; what's the real explanation for this?
             raise UndoError(oid, "_loadBack() failed")
-        data=self.tryToResolveConflict(oid, cserial, serial, bdata, cdata)
+        data = self.tryToResolveConflict(oid, cserial, serial, bdata, cdata)
 
         if data:
             return data, 0, version, snv, ipos
@@ -1243,7 +1243,7 @@
                     vprev=self._tvindex.get(v, 0) or self._vindex.get(v, 0)
                     self._tfile.write(snv + p64(vprev) + v)
                     self._tvindex[v] = here
-                    odlen = DATA_VERSION_HDR_LEN + len(v)+(plen or 8)
+                    odlen = DATA_VERSION_HDR_LEN + len(v) + (plen or 8)
                 else:
                     odlen = DATA_HDR_LEN + (plen or 8)
 
@@ -1387,7 +1387,6 @@
 
                 pindex[oid] = index[oid]
             except Exception, err:
-                raise
                 pindex[oid] = 0
                 error('Bad reference to %s: %s', u64(oid), err)
         return pindex
@@ -1411,7 +1410,7 @@
         index, vindex, tindex, tvindex = self._newIndexes()
         name = self._name
         file = open(name, 'rb')
-        stop = newTimeStamp().raw()
+        stop = timeStampFromTime(t).raw()
         if stop == z64:
             raise FileStorageError, 'Invalid pack time'