Commit cb1fb18e authored by Jim Fulton's avatar Jim Fulton

Fixed undo handling: it wasn't using TransactionMetaData

Also added _s to _transaction_meta_data_text_variables and
_text_transaction_info to mark them as private.
parent 1273166b
...@@ -24,7 +24,7 @@ from . import utils ...@@ -24,7 +24,7 @@ from . import utils
from ZODB.broken import find_global from ZODB.broken import find_global
from ZODB.utils import z64 from ZODB.utils import z64
from ZODB.Connection import Connection from ZODB.Connection import Connection, TransactionMetaData
from ZODB._compat import Pickler, _protocol, BytesIO from ZODB._compat import Pickler, _protocol, BytesIO
import ZODB.serialize import ZODB.serialize
...@@ -901,7 +901,7 @@ class DB(object): ...@@ -901,7 +901,7 @@ class DB(object):
See :meth:`ZODB.interfaces.IStorage.history`. 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): def supportsUndo(self):
"""Return whether the database supports undo. """Return whether the database supports undo.
...@@ -920,7 +920,7 @@ class DB(object): ...@@ -920,7 +920,7 @@ class DB(object):
if not self.supportsUndo(): if not self.supportsUndo():
return () return ()
return text_transaction_info(self.storage.undoLog(*args, **kw)) return _text_transaction_info(self.storage.undoLog(*args, **kw))
def undoInfo(self, *args, **kw): def undoInfo(self, *args, **kw):
"""Return a sequence of descriptions for transactions. """Return a sequence of descriptions for transactions.
...@@ -929,7 +929,7 @@ class DB(object): ...@@ -929,7 +929,7 @@ class DB(object):
""" """
if not self.supportsUndo(): if not self.supportsUndo():
return () 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): def undoMultiple(self, ids, txn=None):
"""Undo multiple transactions identified by ids. """Undo multiple transactions identified by ids.
...@@ -1037,19 +1037,28 @@ class TransactionalUndo(object): ...@@ -1037,19 +1037,28 @@ class TransactionalUndo(object):
pass pass
def tpc_begin(self, transaction): 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): def commit(self, transaction):
transaction = transaction.data(self)
for tid in self._tids: for tid in self._tids:
self._storage.undo(tid, transaction) self._storage.undo(tid, transaction)
def tpc_vote(self, transaction): def tpc_vote(self, transaction):
transaction = transaction.data(self)
self._storage.tpc_vote(transaction) self._storage.tpc_vote(transaction)
def tpc_finish(self, transaction): def tpc_finish(self, transaction):
transaction = transaction.data(self)
self._storage.tpc_finish(transaction) self._storage.tpc_finish(transaction)
def tpc_abort(self, transaction): def tpc_abort(self, transaction):
transaction = transaction.data(self)
self._storage.tpc_abort(transaction) self._storage.tpc_abort(transaction)
def sortKey(self): def sortKey(self):
...@@ -1065,10 +1074,10 @@ def connection(*args, **kw): ...@@ -1065,10 +1074,10 @@ def connection(*args, **kw):
""" """
return DB(*args, **kw).open_then_close_db_when_connection_closes() return DB(*args, **kw).open_then_close_db_when_connection_closes()
transaction_meta_data_text_variables = 'user_name', 'description' _transaction_meta_data_text_variables = 'user_name', 'description'
def text_transaction_info(info): def _text_transaction_info(info):
for d in 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: if name in d:
d[name] = d[name].decode('utf-8') d[name] = d[name].decode('utf-8')
......
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