Commit 065bfea5 authored by Shane Hathaway's avatar Shane Hathaway

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.
parent 606639c4
...@@ -115,7 +115,7 @@ ...@@ -115,7 +115,7 @@
# may have a back pointer to a version record or to a non-version # may have a back pointer to a version record or to a non-version
# record. # record.
# #
__version__='$Revision: 1.84 $'[11:-2] __version__='$Revision: 1.85 $'[11:-2]
import struct, time, os, string, base64, sys import struct, time, os, string, base64, sys
from struct import pack, unpack from struct import pack, unpack
...@@ -877,7 +877,7 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -877,7 +877,7 @@ class FileStorage(BaseStorage.BaseStorage,
self._lock_acquire() self._lock_acquire()
try: try:
self._clear_index() 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:]) tid, tpos = transaction_id[:8], U64(transaction_id[8:])
packt=self._packt packt=self._packt
if packt is None or packt > tid: if packt is None or packt > tid:
...@@ -1061,9 +1061,15 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -1061,9 +1061,15 @@ class FileStorage(BaseStorage.BaseStorage,
# and commitVersion()). In the latter case, we could still find # and commitVersion()). In the latter case, we could still find
# the transaction through an expensive search of the file, but # the transaction through an expensive search of the file, but
# we're punting on that for now. # we're punting on that for now.
transaction_id = base64.decodestring(transaction_id + '\n')
tid = transaction_id[:8] tid = transaction_id[:8]
oid = transaction_id[8:] oid = transaction_id[16:]
if oid == '' or not self._index.has_key(oid): 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' raise UndoError, 'Undoing a non-object affecting transaction'
# Find the file position for the current revision of this object, # Find the file position for the current revision of this object,
# and search back for the beginning of its transaction record # and search back for the beginning of its transaction record
...@@ -1213,14 +1219,19 @@ class FileStorage(BaseStorage.BaseStorage, ...@@ -1213,14 +1219,19 @@ class FileStorage(BaseStorage.BaseStorage,
# #
# Note: if the txn has no data records, we're screwed. Punt # Note: if the txn has no data records, we're screwed. Punt
# on that for now. # 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 = read(8)
# next is either the redundant txn length - 8, or an oid # next is either the redundant txn length - 8, or an oid
if next == tl: if next == tl:
# There were no objects in this txn # There were no objects in this txn
id = tid id = tid + p64(pos)
else: else:
id = tid + next id = tid + p64(pos) + next
d={'id': id, d={'id': encode(id).rstrip(),
'time': TimeStamp(tid).timeTime(), 'time': TimeStamp(tid).timeTime(),
'user_name': u, 'user_name': u,
'description': d} 'description': d}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment