Commit 4300d88a authored by Kirill Smelkov's avatar Kirill Smelkov

X wcfs/xbtreetest/treegen.py: Fix it on ZODB4

There is no TransactionMetaData on ZODB4.
parent 7b0c301c
......@@ -129,7 +129,19 @@ import sys
from golang import func, defer, panic
from golang import time
from ZODB import DB
from ZODB.Connection import Connection, TransactionMetaData
from ZODB.Connection import Connection
# XXX vvv way interferes with recover / sys.exc_info on py2
# TODO -> fix recover on py2
"""
try:
from ZODB.Connection import TransactionMetaData
except ImportError: # ZODB4
TransactionMetaData = None
"""
import ZODB.Connection
TransactionMetaData = getattr(ZODB.Connection, 'TransactionMetaData', None)
from ZODB.MappingStorage import MappingStorage
import transaction
import itertools
......@@ -477,7 +489,10 @@ def commitDelete(obj, description): # -> tid
# deleteObject works only at IStorage level, and at that low level
# zstor requires ZODB.IStorageTransactionMetaData not txn (ITransaction)
if TransactionMetaData is not None:
txn_stormeta = TransactionMetaData(txn.user, description, txn.extension)
else:
txn_stormeta = txn # ZODB4
zstor.tpc_begin(txn_stormeta)
zstor.deleteObject(obj._p_oid, obj._p_serial, txn_stormeta)
zstor.tpc_vote(txn_stormeta)
......
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