[Zope-Checkins] CVS: Zope/lib/python/ZODB - FileStorage.py:1.85

Shane Hathaway shane@cvs.zope.org
Fri, 29 Mar 2002 15:05:01 -0500


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

Modified Files:
	FileStorage.py 
Log Message:
The file position has to be encoded in the transaction ID for non-transactional
undo to continue to work, and the IDs have to be base64 encoded to work on
HTML forms.  In future, non-transactional undo may be removed and the HTML
forms might be updated to perform the encoding of transaction IDs.


=== Zope/lib/python/ZODB/FileStorage.py 1.84 => 1.85 ===
         try:
             self._clear_index()
-            transaction_id=base64.decodestring(transaction_id+'==\n')
+            transaction_id=base64.decodestring(transaction_id + '\n')
             tid, tpos = transaction_id[:8], U64(transaction_id[8:])
             packt=self._packt
             if packt is None or packt > tid:
@@ -1061,9 +1061,15 @@
             # and commitVersion()).  In the latter case, we could still find
             # the transaction through an expensive search of the file, but
             # we're punting on that for now.
+            transaction_id = base64.decodestring(transaction_id + '\n')
             tid = transaction_id[:8]
-            oid = transaction_id[8:]
+            oid = transaction_id[16:]
             if oid == '' or not self._index.has_key(oid):
+                # We can't get the position of the transaction easily.
+                # Note that there is a position encoded in the
+                # transaction_id at [8:16], but it can't be used reliably
+                # across multiple file storages and thus breaks
+                # transactional integrity.
                 raise UndoError, 'Undoing a non-object affecting transaction'
             # Find the file position for the current revision of this object,
             # and search back for the beginning of its transaction record
@@ -1213,14 +1219,19 @@
                 #
                 # Note: if the txn has no data records, we're screwed.  Punt
                 # on that for now.
+                #
+                # Note that we're still encoding the transaction position
+                # in the transaction ID in order to support non-transactional
+                # undo.  This can be removed as soon as non-transactional
+                # undo is removed.
                 next = read(8)
                 # next is either the redundant txn length - 8, or an oid
                 if next == tl:
                     # There were no objects in this txn
-                    id = tid
+                    id = tid + p64(pos)
                 else:
-                    id = tid + next
-                d={'id': id,
+                    id = tid + p64(pos) + next
+                d={'id': encode(id).rstrip(),
                    'time': TimeStamp(tid).timeTime(),
                    'user_name': u,
                    'description': d}