Skip to content

Commit

Permalink
Fixed undo handling: it wasn't using TransactionMetaData
Browse files Browse the repository at this point in the history
Also added _s to _transaction_meta_data_text_variables and
_text_transaction_info to mark them as private.
  • Loading branch information
Jim Fulton committed Nov 17, 2016
1 parent 1273166 commit cb1fb18
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions src/ZODB/DB.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

from ZODB.broken import find_global
from ZODB.utils import z64
from ZODB.Connection import Connection
from ZODB.Connection import Connection, TransactionMetaData
from ZODB._compat import Pickler, _protocol, BytesIO
import ZODB.serialize

Expand Down Expand Up @@ -901,7 +901,7 @@ def history(self, oid, size=1):
See :meth:`ZODB.interfaces.IStorage.history`.
"""
return text_transaction_info(self.storage.history(oid, size))
return _text_transaction_info(self.storage.history(oid, size))

def supportsUndo(self):
"""Return whether the database supports undo.
Expand All @@ -920,7 +920,7 @@ def undoLog(self, *args, **kw):

if not self.supportsUndo():
return ()
return text_transaction_info(self.storage.undoLog(*args, **kw))
return _text_transaction_info(self.storage.undoLog(*args, **kw))

def undoInfo(self, *args, **kw):
"""Return a sequence of descriptions for transactions.
Expand All @@ -929,7 +929,7 @@ def undoInfo(self, *args, **kw):
"""
if not self.supportsUndo():
return ()
return text_transaction_info(self.storage.undoInfo(*args, **kw))
return _text_transaction_info(self.storage.undoInfo(*args, **kw))

def undoMultiple(self, ids, txn=None):
"""Undo multiple transactions identified by ids.
Expand Down Expand Up @@ -1037,19 +1037,28 @@ def abort(self, transaction):
pass

def tpc_begin(self, transaction):
self._storage.tpc_begin(transaction)
tdata = TransactionMetaData(
transaction.user,
transaction.description,
transaction.extended_info)
transaction.set_data(self, tdata)
self._storage.tpc_begin(tdata)

def commit(self, transaction):
transaction = transaction.data(self)
for tid in self._tids:
self._storage.undo(tid, transaction)

def tpc_vote(self, transaction):
transaction = transaction.data(self)
self._storage.tpc_vote(transaction)

def tpc_finish(self, transaction):
transaction = transaction.data(self)
self._storage.tpc_finish(transaction)

def tpc_abort(self, transaction):
transaction = transaction.data(self)
self._storage.tpc_abort(transaction)

def sortKey(self):
Expand All @@ -1065,10 +1074,10 @@ def connection(*args, **kw):
"""
return DB(*args, **kw).open_then_close_db_when_connection_closes()

transaction_meta_data_text_variables = 'user_name', 'description'
def text_transaction_info(info):
_transaction_meta_data_text_variables = 'user_name', 'description'
def _text_transaction_info(info):
for d in info:
for name in transaction_meta_data_text_variables:
for name in _transaction_meta_data_text_variables:
if name in d:
d[name] = d[name].decode('utf-8')

Expand Down

0 comments on commit cb1fb18

Please sign in to comment.