Commit 051b0f7d authored by Grégory Wisniewski's avatar Grégory Wisniewski

Insert extension's data in transaction informations returned to ZODB.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1965 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 70dcd0fb
......@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from thread import get_ident
from cPickle import dumps
from cPickle import dumps, loads
from zlib import compress as real_compress, decompress
from neo.locking import Queue, Empty
from random import shuffle
......@@ -786,6 +786,7 @@ class Application(object):
continue
self.local_var.txn_info = 0
self.local_var.txn_ext = 0
try:
self._askStorage(conn, Packets.AskTransactionInformation(
undone_tid))
......@@ -831,6 +832,10 @@ class Application(object):
self.waitStoreResponses(tryToResolveConflict)
return self.local_var.tid, oid_list
def _insertMetadata(self, txn_info, extension):
for k, v in loads(extension).items():
txn_info[k] = v
def __undoLog(self, first, last, filter=None, block=0, with_oids=False):
if last < 0:
# See FileStorage.py for explanation
......@@ -871,6 +876,7 @@ class Application(object):
conn = self.cp.getConnForCell(cell)
if conn is not None:
self.local_var.txn_info = 0
self.local_var.txn_ext = 0
try:
self._askStorage(conn,
Packets.AskTransactionInformation(tid))
......@@ -890,6 +896,8 @@ class Application(object):
if not with_oids:
self.local_var.txn_info.pop("oids")
append(self.local_var.txn_info)
self._insertMetadata(self.local_var.txn_info,
self.local_var.txn_ext)
if len(undo_info) >= last - first:
break
# Check we return at least one element, otherwise call
......@@ -977,6 +985,8 @@ class Application(object):
self.local_var.txn_info['size'] = size
if filter is None or filter(self.local_var.txn_info):
history_list.append(self.local_var.txn_info)
self._insertMetadata(self.local_var.txn_info,
self.local_var.txn_ext)
return history_list
......
......@@ -91,6 +91,7 @@ class StorageAnswersHandler(AnswerBaseHandler):
info['id'] = tid
info['oids'] = oid_list
info['packed'] = packed
self.app.local_var.txn_ext = ext
self.app.local_var.txn_info = info
def answerObjectHistory(self, conn, oid, history_list):
......
......@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import unittest
from cPickle import dumps
from mock import Mock, ReturnValues
from ZODB.POSException import StorageTransactionError, UndoError, ConflictError
from neo.tests import NeoTestBase
......@@ -802,10 +803,11 @@ class ClientApplicationTests(NeoTestBase):
oid1, oid2 = self.makeOID(1), self.makeOID(2)
# TIDs packets supplied by _waitMessage hook
# TXN info packets
p3 = Packets.AnswerTransactionInformation(tid1, '', '', '',
False, (oid1, ))
p4 = Packets.AnswerTransactionInformation(tid2, '', '', '',
False, (oid2, ))
extension = dumps({})
p3 = Packets.AnswerTransactionInformation(tid1, '', '',
extension, False, (oid1, ))
p4 = Packets.AnswerTransactionInformation(tid2, '', '',
extension, False, (oid2, ))
p3.setId(0)
p4.setId(1)
conn = Mock({
......@@ -837,12 +839,22 @@ class ClientApplicationTests(NeoTestBase):
tid1, tid2 = self.makeTID(1), self.makeTID(2)
object_history = ( (tid1, 42), (tid2, 42),)
# object history, first is a wrong oid, second is valid
<<<<<<< HEAD
p2 = Packets.AnswerObjectHistory(oid, object_history)
# transaction history
p3 = Packets.AnswerTransactionInformation(tid1, 'u', 'd', 'e',
False, (oid, ))
p4 = Packets.AnswerTransactionInformation(tid2, 'u', 'd', 'e',
False, (oid, ))
=======
p2 = Packets.AnswerObjectHistory('', oid, object_history)
extension = dumps({'k': 'v'})
# transaction history
p3 = Packets.AnswerTransactionInformation('export', tid1, 'u', 'd',
extension, False, (oid, ))
p4 = Packets.AnswerTransactionInformation('export', tid2, 'u', 'd',
extension, False, (oid, ))
>>>>>>> f540962... Insert extension's data in transaction informations returned to ZODB.
p2.setId(0)
p3.setId(1)
p4.setId(2)
......
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