Commit 2d8d3804 authored by Vincent Pelletier's avatar Vincent Pelletier

Allow manually enabling "old" ZODB API compatibility.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2474 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 41b537c8
...@@ -21,6 +21,7 @@ from zlib import compress as real_compress, decompress ...@@ -21,6 +21,7 @@ from zlib import compress as real_compress, decompress
from neo.locking import Queue, Empty from neo.locking import Queue, Empty
from random import shuffle from random import shuffle
import time import time
import os
from ZODB.POSException import UndoError, StorageTransactionError, ConflictError from ZODB.POSException import UndoError, StorageTransactionError, ConflictError
from ZODB.ConflictResolution import ResolvedSerial from ZODB.ConflictResolution import ResolvedSerial
...@@ -62,6 +63,13 @@ else: ...@@ -62,6 +63,13 @@ else:
compress = real_compress compress = real_compress
makeChecksum = real_makeChecksum makeChecksum = real_makeChecksum
# Set environment variable to non-empty value to ignore:
# - multiple calls to tpc_begin for same transaction
# - tpc_finish called for different transaction
# This is needed to conform to the "old" ZODB API (ex: 3.4).
RELAX_TRANSACTION_CHECKS = bool(os.getenv('NEO_RELAX_TRANSACTION_CHECKS',
False))
class ThreadContext(object): class ThreadContext(object):
def __init__(self): def __init__(self):
...@@ -609,6 +617,8 @@ class Application(object): ...@@ -609,6 +617,8 @@ class Application(object):
# First get a transaction, only one is allowed at a time # First get a transaction, only one is allowed at a time
if self.local_var.txn is transaction: if self.local_var.txn is transaction:
# We already begin the same transaction # We already begin the same transaction
if RELAX_TRANSACTION_CHECKS:
return
raise StorageTransactionError('Duplicate tpc_begin calls') raise StorageTransactionError('Duplicate tpc_begin calls')
if self.local_var.txn is not None: if self.local_var.txn is not None:
raise NeoException, 'local_var is not clean in tpc_begin' raise NeoException, 'local_var is not clean in tpc_begin'
...@@ -865,6 +875,8 @@ class Application(object): ...@@ -865,6 +875,8 @@ class Application(object):
"""Finish current transaction.""" """Finish current transaction."""
local_var = self.local_var local_var = self.local_var
if local_var.txn is not transaction: if local_var.txn is not transaction:
if RELAX_TRANSACTION_CHECKS:
return
raise StorageTransactionError('tpc_finish called for wrong ' raise StorageTransactionError('tpc_finish called for wrong '
'transaction') 'transaction')
if not local_var.txn_voted: if not local_var.txn_voted:
......
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