Commit a0972725 authored by Jeremy Hylton's avatar Jeremy Hylton

Replace use of builtin get_transaction() with explicit transaction module.

parent 62447db4
......@@ -20,9 +20,9 @@ def convert(old, new, threshold=200, f=None):
new[k]=v
n=n+1
if n > threshold:
get_transaction().commit(1)
transaction.commit(1)
old._p_jar.cacheMinimize()
n=0
get_transaction().commit(1)
transaction.commit(1)
old._p_jar.cacheMinimize()
......@@ -21,6 +21,7 @@ from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
from BTrees.check import check
import transaction
from ZODB import DB
from ZODB.MappingStorage import MappingStorage
......@@ -56,7 +57,7 @@ class Base(TestCase):
root = None
root = self._getRoot()
root[i] = t
get_transaction().commit()
transaction.commit()
root2 = self._getRoot()
if hasattr(t, 'items'):
......@@ -73,11 +74,11 @@ class Base(TestCase):
self._populate(t, i)
root = self._getRoot()
root[i] = t
get_transaction().commit()
transaction.commit()
root2 = self._getRoot()
root2[i]._p_deactivate()
get_transaction().commit()
transaction.commit()
if hasattr(t, 'items'):
self.assertEqual(list(root2[i].items()) , list(t.items()))
else:
......
......@@ -19,6 +19,7 @@ from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
import transaction
from ZODB.POSException import ConflictError
class Base:
......@@ -27,7 +28,7 @@ class Base:
storage = None
def tearDown(self):
get_transaction().abort()
transaction.abort()
del self.t
if self.storage is not None:
self.storage.close()
......@@ -75,7 +76,7 @@ class MappingBase(Base):
r1 = self.db.open().root()
r1["t"] = self.t
get_transaction().commit()
transaction.commit()
r2 = self.db.open().root()
copy = r2["t"]
......@@ -84,10 +85,10 @@ class MappingBase(Base):
self.assertEqual(self.t._p_serial, copy._p_serial)
self.t.update({1:2, 2:3})
get_transaction().commit()
transaction.commit()
copy.update({3:4})
get_transaction().commit()
transaction.commit()
def testMergeDelete(self):
......@@ -427,7 +428,7 @@ class NastyConfict(Base, TestCase):
r1 = self.db.open().root()
r1["t"] = self.t
get_transaction().commit()
transaction.commit()
r2 = self.db.open().root()
copy = r2["t"]
......@@ -437,10 +438,10 @@ class NastyConfict(Base, TestCase):
self.assertEqual(self.t._p_serial, copy._p_serial)
self.t.update({1:2, 2:3})
get_transaction().commit()
transaction.commit()
copy.update({3:4})
get_transaction().commit() # if this doesn't blow up
transaction.commit() # if this doesn't blow up
list(copy.values()) # and this doesn't either, then fine
def testBucketSplitConflict(self):
......@@ -467,7 +468,7 @@ class NastyConfict(Base, TestCase):
r1 = self.db.open().root()
r1["t"] = self.t
get_transaction().commit()
transaction.commit()
r2 = self.db.open(synch=False).root()
copy = r2["t"]
......@@ -499,7 +500,7 @@ class NastyConfict(Base, TestCase):
self.assertEqual(state[0][3], 75)
self.assertEqual(state[0][5], 120)
get_transaction().commit()
transaction.commit()
# In the other transaction, add 3 values near the tail end of bucket1.
# This doesn't cause a split.
......@@ -517,8 +518,8 @@ class NastyConfict(Base, TestCase):
self.assertEqual(state[0][1], 60)
self.assertEqual(state[0][3], 120)
self.assertRaises(ConflictError, get_transaction().commit)
get_transaction().abort() # horrible things happen w/o this
self.assertRaises(ConflictError, transaction.commit)
transaction.abort() # horrible things happen w/o this
def testEmptyBucketConflict(self):
# Tests that an emptied bucket *created by* conflict resolution is
......@@ -544,7 +545,7 @@ class NastyConfict(Base, TestCase):
r1 = self.db.open().root()
r1["t"] = self.t
get_transaction().commit()
transaction.commit()
r2 = self.db.open(synch=False).root()
copy = r2["t"]
......@@ -568,7 +569,7 @@ class NastyConfict(Base, TestCase):
self.assertEqual(state[0][1], 60)
self.assertEqual(state[0][3], 120)
get_transaction().commit()
transaction.commit()
# In the other transaction, delete the other half of bucket 1.
b = copy
......@@ -589,8 +590,8 @@ class NastyConfict(Base, TestCase):
# create an "insane" BTree (a legit BTree cannot contain an empty
# bucket -- it contains NULL pointers the BTree code doesn't
# expect, and segfaults result).
self.assertRaises(ConflictError, get_transaction().commit)
get_transaction().abort() # horrible things happen w/o this
self.assertRaises(ConflictError, transaction.commit)
transaction.abort() # horrible things happen w/o this
def testEmptyBucketNoConflict(self):
......@@ -616,7 +617,7 @@ class NastyConfict(Base, TestCase):
r1 = self.db.open().root()
r1["t"] = self.t
get_transaction().commit()
transaction.commit()
r2 = self.db.open().root()
copy = r2["t"]
......@@ -639,7 +640,7 @@ class NastyConfict(Base, TestCase):
self.assertEqual(state[0][1], 60)
self.assertEqual(state[0][3], 120)
get_transaction().commit()
transaction.commit()
# In the other transaction, delete bucket 2.
b = copy
......@@ -655,7 +656,7 @@ class NastyConfict(Base, TestCase):
self.assertEqual(state[0][1], 60)
# This shouldn't create a ConflictError.
get_transaction().commit()
transaction.commit()
# And the resulting BTree shouldn't have internal damage.
b._check()
......@@ -685,7 +686,7 @@ class NastyConfict(Base, TestCase):
self.openDB()
r1 = self.db.open().root()
r1["t"] = self.t
get_transaction().commit()
transaction.commit()
r2 = self.db.open(synch=False).root()
copy = r2["t"]
......@@ -699,16 +700,16 @@ class NastyConfict(Base, TestCase):
for k in range(200, 300, 4):
self.t[k] = k
get_transaction().commit()
transaction.commit()
for k in range(0, 60, 4):
del copy[k]
try:
get_transaction().commit()
transaction.commit()
except ConflictError, detail:
self.assert_(str(detail).startswith('database conflict error'))
get_transaction().abort()
transaction.abort()
else:
self.fail("expected ConflictError")
......
......@@ -15,11 +15,12 @@
import unittest
from BTrees.OOBTree import OOBucket as Bucket, OOSet as Set
import transaction
from ZODB.MappingStorage import MappingStorage
from ZODB.DB import DB
from BTrees.OOBTree import OOBucket as Bucket, OOSet as Set
class CompareTest(unittest.TestCase):
s = "A string with hi-bit-set characters: \700\701"
......@@ -35,7 +36,7 @@ class CompareTest(unittest.TestCase):
root = self.db.open().root()
self.bucket = root["bucket"] = Bucket()
self.set = root["set"] = Set()
get_transaction().commit()
transaction.commit()
def tearDown(self):
self.assert_(self.bucket._p_changed != 2)
......
......@@ -39,7 +39,7 @@ from ZODB.POSException \
# of obscure timing-related bugs in cache consistency logic, revealed
# by failure of the BTree to pass internal consistency checks at the end,
# and/or by failure of the BTree to contain all the keys the threads
# thought they added (i.e., the keys for which get_transaction().commit()
# thought they added (i.e., the keys for which transaction.commit()
# did not raise any exception).
class FailableThread(TestThread):
......@@ -151,19 +151,19 @@ class StressThread(FailableThread):
tree = cn.root()["tree"]
break
except (ConflictError, KeyError):
get_transaction().abort()
transaction.abort()
cn.sync()
key = self.startnum
while not self.stop.isSet():
try:
tree[key] = self.threadnum
get_transaction().note("add key %s" % key)
get_transaction().commit()
transaction.get().note("add key %s" % key)
transaction.commit()
self.commitdict[self] = 1
if self.sleep:
time.sleep(self.sleep)
except (ReadConflictError, ConflictError), msg:
get_transaction().abort()
transaction.abort()
# sync() is necessary here to process invalidations
# if we get a read conflict. In the read conflict case,
# no objects were modified so cn never got registered
......@@ -209,7 +209,7 @@ class LargeUpdatesThread(FailableThread):
break
except (ConflictError, KeyError):
# print "%d getting tree abort" % self.threadnum
get_transaction().abort()
transaction.abort()
cn.sync()
keys_added = {} # set of keys we commit
......@@ -231,20 +231,20 @@ class LargeUpdatesThread(FailableThread):
tree[key] = self.threadnum
except (ReadConflictError, ConflictError), msg:
# print "%d setting key %s" % (self.threadnum, msg)
get_transaction().abort()
transaction.abort()
cn.sync()
break
else:
# print "%d set #%d" % (self.threadnum, len(keys))
get_transaction().note("keys %s" % ", ".join(map(str, keys)))
transaction.get().note("keys %s" % ", ".join(map(str, keys)))
try:
get_transaction().commit()
transaction.commit()
self.commitdict[self] = 1
if self.sleep:
time.sleep(self.sleep)
except ConflictError, msg:
# print "%d commit %s" % (self.threadnum, msg)
get_transaction().abort()
transaction.abort()
cn.sync()
continue
for k in keys:
......@@ -304,17 +304,17 @@ class VersionStressThread(FailableThread):
tree = cn.root()["tree"]
break
except (ConflictError, KeyError):
get_transaction().abort()
transaction.abort()
cn.sync()
while not self.stop.isSet():
try:
tree[key] = self.threadnum
get_transaction().commit()
transaction.commit()
if self.sleep:
time.sleep(self.sleep)
break
except (VersionLockError, ReadConflictError, ConflictError), msg:
get_transaction().abort()
transaction.abort()
# sync() is necessary here to process invalidations
# if we get a read conflict. In the read conflict case,
# no objects were modified so cn never got registered
......@@ -327,16 +327,16 @@ class VersionStressThread(FailableThread):
try:
if commit:
self.db.commitVersion(version)
get_transaction().note("commit version %s" % version)
transaction.get().note("commit version %s" % version)
else:
self.db.abortVersion(version)
get_transaction().note("abort version %s" % version)
get_transaction().commit()
transaction.get().note("abort version %s" % version)
transaction.commit()
if self.sleep:
time.sleep(self.sleep)
return commit
except ConflictError, msg:
get_transaction().abort()
transaction.abort()
cn.sync()
finally:
cn.close()
......@@ -368,7 +368,7 @@ class InvalidationTests:
tree._check()
except ReadConflictError:
if retries:
get_transaction().abort()
transaction.abort()
cn.sync()
else:
raise
......@@ -427,7 +427,7 @@ class InvalidationTests:
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
get_transaction().commit()
transaction.commit()
# DM: allow time for invalidations to come in and process them
time.sleep(0.1)
......@@ -453,7 +453,7 @@ class InvalidationTests:
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
get_transaction().commit()
transaction.commit()
cn.close()
# Run two threads that update the BTree
......@@ -482,7 +482,7 @@ class InvalidationTests:
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
get_transaction().commit()
transaction.commit()
cn.close()
# Run two threads that update the BTree
......@@ -507,7 +507,7 @@ class InvalidationTests:
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
get_transaction().commit()
transaction.commit()
cn.close()
# Run three threads that update the BTree.
......@@ -543,7 +543,7 @@ class InvalidationTests:
cn = db1.open()
tree = cn.root()["tree"] = OOBTree()
get_transaction().commit()
transaction.commit()
cn.close()
# Run three threads that update the BTree.
......@@ -582,7 +582,7 @@ class InvalidationTests:
tree = cn.root()["tree"] = OOBTree()
for i in range(0, 3000, 2):
tree[i] = 0
get_transaction().commit()
transaction.commit()
cn.close()
# Run three threads that update the BTree.
......@@ -608,7 +608,7 @@ class InvalidationTests:
losers = [k for k, v in tree.items() if v == 0]
for k in losers:
del tree[k]
get_transaction().commit()
transaction.commit()
self._check_threads(tree, t1, t2, t3)
......
......@@ -25,7 +25,7 @@ def main():
update(r1, r2)
except ConflictError, msg:
print msg
get_transaction().abort()
transaction.abort()
c1.sync()
c2.sync()
except (ClientDisconnected, DisconnectedError), err:
......@@ -41,7 +41,7 @@ def update(r1, r2):
random.shuffle(updates)
for key, root in updates:
root[key] = time.time()
get_transaction().commit()
transaction.commit()
print os.getpid(), k1, k2
if __name__ == "__main__":
......
......@@ -17,6 +17,7 @@
import ZODB, ZODB.DB, ZODB.FileStorage, ZODB.POSException
import persistent
import persistent.mapping
import transaction
from ZEO.tests import forker
import os
......@@ -57,7 +58,7 @@ def init_storage():
db = ZODB.DB(fs)
root = db.open().root()
root["multi"] = persistent.mapping.PersistentMapping()
get_transaction().commit()
transaction.commit()
return fs
......@@ -95,9 +96,9 @@ def run(storage):
while 1:
try:
s = root[pid] = Stats()
get_transaction().commit()
transaction.commit()
except ZODB.POSException.ConflictError:
get_transaction().abort()
transaction.abort()
time.sleep(CONFLICT_DELAY)
else:
break
......@@ -111,16 +112,16 @@ def run(storage):
r = dict[size] = Record(pid, size)
if prev:
prev.set_next(r)
get_transaction().commit()
transaction.commit()
except ZODB.POSException.ConflictError, err:
get_transaction().abort()
transaction.abort()
time.sleep(CONFLICT_DELAY)
else:
i = i + 1
if VERBOSE and (i < 5 or i % 10 == 0):
print "Client %s: %s of %s" % (pid, i, RECORDS_PER_CLIENT)
s.done()
get_transaction().commit()
transaction.commit()
print "Client completed:", pid
......
......@@ -45,10 +45,11 @@ import asyncore
import sys, os, getopt, time
##sys.path.insert(0, os.getcwd())
import ZODB
import persistent
from ZEO.tests import forker
import transaction
import ZODB
from ZODB.POSException import ConflictError
from ZEO.tests import forker
class P(persistent.Persistent):
pass
......@@ -84,7 +85,7 @@ def work(db, results, nrep, compress, data, detailed, minimize, threadno=None):
jar = db.open()
while 1:
try:
get_transaction().begin()
transaction.begin()
rt = jar.root()
key = 's%s' % r
if rt.has_key(key):
......@@ -98,7 +99,7 @@ def work(db, results, nrep, compress, data, detailed, minimize, threadno=None):
else:
v.d = data
setattr(p, str(i), v)
get_transaction().commit()
transaction.commit()
except ConflictError:
conflicts = conflicts + 1
else:
......
......@@ -18,11 +18,12 @@ multiple connections.
"""
# XXX This code is currently broken.
import transaction
import ZODB
from ZEO.ClientStorage import ClientStorage
from ZODB.MappingStorage import MappingStorage
from ZEO.tests import forker
from ZODB.tests import MinPO
from ZEO.ClientStorage import ClientStorage
from ZEO.tests import forker
import os
import random
......@@ -59,7 +60,7 @@ def setup(cn):
o = MinPO.MinPO(prev)
prev = o
root[an_object()] = o
get_transaction().commit()
transaction.commit()
cn.close()
def work(cn):
......@@ -71,7 +72,7 @@ def work(cn):
while not isinstance(obj.value, types.StringType):
obj = obj.value
obj.value = an_object()
get_transaction().commit()
transaction.commit()
def main():
# Yuck! Need to cleanup forker so that the API is consistent
......
......@@ -55,7 +55,8 @@ class BasicStorage:
assert 0, "Should have failed, invalid transaction."
try:
self._storage.commitVersion('dummy', 'dummer', transaction.Transaction())
self._storage.commitVersion('dummy', 'dummer',
transaction.Transaction())
except (POSException.StorageTransactionError,
POSException.VersionCommitError):
pass # test passed ;)
......
......@@ -72,7 +72,7 @@ class ZODBClientThread(TestThread):
def commit(self, d, num):
d[num] = time.time()
time.sleep(self.delay)
get_transaction().commit()
transaction.commit()
time.sleep(self.delay)
def get_thread_dict(self, root):
......@@ -82,16 +82,16 @@ class ZODBClientThread(TestThread):
try:
m = PersistentMapping()
root[name] = m
get_transaction().commit()
transaction.commit()
break
except ConflictError, err:
get_transaction().abort()
transaction.abort()
root._p_jar.sync()
for i in range(10):
try:
return root.get(name)
except ConflictError:
get_transaction().abort()
transaction.abort()
class StorageClientThread(TestThread):
......
......@@ -27,9 +27,10 @@ except ImportError:
import time
from ZODB import DB
from persistent import Persistent
from persistent.mapping import PersistentMapping
import transaction
from ZODB import DB
from ZODB.serialize import referencesf
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import snooze
......@@ -164,7 +165,7 @@ class PackableStorage(PackableStorageBase):
for i in range(10):
root[i] = MinPO(i)
get_transaction().commit()
transaction.commit()
snooze()
packt = time.time()
......@@ -173,7 +174,7 @@ class PackableStorage(PackableStorageBase):
for dummy in choices:
for i in choices:
root[i].value = MinPO(i)
get_transaction().commit()
transaction.commit()
# How many client threads should we run, and how long should we
# wait for them to finish? Hard to say. Running 4 threads and
......@@ -274,7 +275,7 @@ class PackableStorage(PackableStorageBase):
choices = range(10)
for i in choices:
root[i] = MinPO(i)
get_transaction().commit()
transaction.commit()
snooze()
packt = time.time()
......@@ -282,7 +283,7 @@ class PackableStorage(PackableStorageBase):
for dummy in choices:
for i in choices:
root[i].value = MinPO(i)
get_transaction().commit()
transaction.commit()
NUM_LOOP_TRIP = 100
timer = ElapsedTimer(time.time())
......@@ -500,7 +501,7 @@ class PackableUndoStorage(PackableStorageBase):
conn = db.open()
root = conn.root()
txn = get_transaction()
txn = transaction.get()
txn.note('root')
txn.commit()
......@@ -512,12 +513,12 @@ class PackableUndoStorage(PackableStorageBase):
obj.value = 7
root['obj'] = obj
txn = get_transaction()
txn = transaction.get()
txn.note('root -> o1')
txn.commit()
del root['obj']
txn = get_transaction()
txn = transaction.get()
txn.note('root -x-> o1')
txn.commit()
......@@ -526,7 +527,7 @@ class PackableUndoStorage(PackableStorageBase):
log = self._storage.undoLog()
tid = log[0]['id']
db.undo(tid)
txn = get_transaction()
txn = transaction.get()
txn.note('undo root -x-> o1')
txn.commit()
......@@ -552,19 +553,19 @@ class PackableUndoStorage(PackableStorageBase):
root = conn.root()
root["d"] = d = PersistentMapping()
get_transaction().commit()
transaction.commit()
snooze()
obj = d["obj"] = C()
obj.value = 1
get_transaction().commit()
transaction.commit()
snooze()
packt1 = time.time()
lost_oid = obj._p_oid
obj = d["anotherobj"] = C()
obj.value = 2
get_transaction().commit()
transaction.commit()
snooze()
packt2 = time.time()
......@@ -682,13 +683,13 @@ class ClientThread(TestThread):
alist.extend([self.millis(), index])
self.root[index].value = MinPO(j)
assign_worked = True
get_transaction().commit()
transaction.commit()
alist.append(self.millis())
alist.append('OK')
except ConflictError:
alist.append(self.millis())
alist.append('Conflict')
get_transaction().abort()
transaction.abort()
alist.append(assign_worked)
class ElapsedTimer:
......
......@@ -13,6 +13,7 @@
##############################################################################
"""More recovery and iterator tests."""
import transaction
from transaction import Transaction
from ZODB.tests.IteratorStorage import IteratorDeepCompare
from ZODB.tests.StorageTestBase import MinPO, zodb_unpickle, snooze
......@@ -134,9 +135,9 @@ class RecoveryStorage(IteratorDeepCompare):
c = db.open()
r = c.root()
obj = r["obj1"] = MinPO(1)
get_transaction().commit()
transaction.commit()
obj = r["obj2"] = MinPO(1)
get_transaction().commit()
transaction.commit()
self._dst.copyTransactionsFrom(self._storage)
self._dst.pack(time.time(), referencesf)
......@@ -161,15 +162,15 @@ class RecoveryStorage(IteratorDeepCompare):
conn = db.open()
root = conn.root()
root.obj = obj1 = MinPO(1)
txn = get_transaction()
txn = transaction.get()
txn.note('root -> obj')
txn.commit()
root.obj.obj = obj2 = MinPO(2)
txn = get_transaction()
txn = transaction.get()
txn.note('root -> obj -> obj')
txn.commit()
del root.obj
txn = get_transaction()
txn = transaction.get()
txn.note('root -X->')
txn.commit()
# Now copy the transactions to the destination
......
......@@ -20,6 +20,7 @@ import time
import types
from persistent import Persistent
import transaction
from transaction import Transaction
from ZODB import POSException
......@@ -468,7 +469,7 @@ class TransactionalUndoStorage:
o2 = C()
root['obj'] = o1
o1.obj = o2
txn = get_transaction()
txn = transaction.get()
txn.note('o1 -> o2')
txn.commit()
now = packtime = time.time()
......@@ -477,12 +478,12 @@ class TransactionalUndoStorage:
o3 = C()
o2.obj = o3
txn = get_transaction()
txn = transaction.get()
txn.note('o1 -> o2 -> o3')
txn.commit()
o1.obj = o3
txn = get_transaction()
txn = transaction.get()
txn.note('o1 -> o3')
txn.commit()
......@@ -500,7 +501,7 @@ class TransactionalUndoStorage:
tid = log[0]['id']
db.undo(tid)
txn = get_transaction()
txn = transaction.get()
txn.note('undo')
txn.commit()
# undo does a txn-undo, but doesn't invalidate
......@@ -527,14 +528,14 @@ class TransactionalUndoStorage:
root["key0"] = MinPO(0)
root["key1"] = MinPO(1)
root["key2"] = MinPO(2)
txn = get_transaction()
txn = transaction.get()
txn.note("create 3 keys")
txn.commit()
set_pack_time()
del root["key1"]
txn = get_transaction()
txn = transaction.get()
txn.note("delete 1 key")
txn.commit()
......@@ -546,7 +547,7 @@ class TransactionalUndoStorage:
L = db.undoInfo()
db.undo(L[0]["id"])
txn = get_transaction()
txn = transaction.get()
txn.note("undo deletion")
txn.commit()
......@@ -574,11 +575,11 @@ class TransactionalUndoStorage:
rt = cn.root()
rt["test"] = MinPO(1)
get_transaction().commit()
transaction.commit()
rt["test2"] = MinPO(2)
get_transaction().commit()
transaction.commit()
rt["test"] = MinPO(3)
txn = get_transaction()
txn = transaction.get()
txn.note("root of undo")
txn.commit()
......@@ -586,7 +587,7 @@ class TransactionalUndoStorage:
for i in range(10):
L = db.undoInfo()
db.undo(L[0]["id"])
txn = get_transaction()
txn = transaction.get()
txn.note("undo %d" % i)
txn.commit()
rt._p_deactivate()
......@@ -706,7 +707,7 @@ class TransactionalUndoStorage:
def checkUndoLogMetadata(self):
# test that the metadata is correct in the undo log
t = get_transaction()
t = transaction.get()
t.note('t1')
t.setExtendedInfo('k2','this is transaction metadata')
t.setUser('u3',path='p3')
......@@ -715,7 +716,7 @@ class TransactionalUndoStorage:
root = conn.root()
o1 = C()
root['obj'] = o1
txn = get_transaction()
txn = transaction.get()
txn.commit()
l = self._storage.undoLog()
self.assertEqual(len(l),2)
......
......@@ -18,6 +18,7 @@ Any storage that supports versions should be able to pass all these tests.
import time
import transaction
from transaction import Transaction
from ZODB import POSException
......@@ -394,12 +395,12 @@ class VersionStorage:
obj = root["obj"] = MinPO("obj")
root["obj2"] = MinPO("obj2")
txn = get_transaction()
txn = transaction.get()
txn.note("create 2 objs in version")
txn.commit()
obj.value = "77"
txn = get_transaction()
txn = transaction.get()
txn.note("modify obj in version")
txn.commit()
......@@ -407,7 +408,7 @@ class VersionStorage:
# and versions for pack to chase
info = db.undoInfo()
db.undo(info[0]["id"])
txn = get_transaction()
txn = transaction.get()
txn.note("undo modification")
txn.commit()
......@@ -415,7 +416,7 @@ class VersionStorage:
self._storage.pack(time.time(), referencesf)
db.commitVersion("testversion")
txn = get_transaction()
txn = transaction.get()
txn.note("commit version")
txn.commit()
......@@ -423,7 +424,7 @@ class VersionStorage:
root = cn.root()
root["obj"] = "no version"
txn = get_transaction()
txn = transaction.get()
txn.note("modify obj")
txn.commit()
......@@ -436,12 +437,12 @@ class VersionStorage:
obj = root["obj"] = MinPO("obj")
root["obj2"] = MinPO("obj2")
txn = get_transaction()
txn = transaction.get()
txn.note("create 2 objs in version")
txn.commit()
obj.value = "77"
txn = get_transaction()
txn = transaction.get()
txn.note("modify obj in version")
txn.commit()
......@@ -452,14 +453,14 @@ class VersionStorage:
# and versions for pack to chase
info = db.undoInfo()
db.undo(info[0]["id"])
txn = get_transaction()
txn = transaction.get()
txn.note("undo modification")
txn.commit()
self._storage.pack(t0, referencesf)
db.commitVersion("testversion")
txn = get_transaction()
txn = transaction.get()
txn.note("commit version")
txn.commit()
......@@ -467,7 +468,7 @@ class VersionStorage:
root = cn.root()
root["obj"] = "no version"
txn = get_transaction()
txn = transaction.get()
txn.note("modify obj")
txn.commit()
......@@ -482,18 +483,18 @@ class VersionStorage:
for name in names:
root[name] = MinPO(name)
get_transaction().commit()
transaction.commit()
for name in names:
cn2 = db.open(version=name)
rt2 = cn2.root()
obj = rt2[name]
obj.value = MinPO("version")
get_transaction().commit()
transaction.commit()
cn2.close()
root["d"] = MinPO("d")
get_transaction().commit()
transaction.commit()
snooze()
self._storage.pack(time.time(), referencesf)
......@@ -511,11 +512,11 @@ class VersionStorage:
obj = rt2[name].value
self.assertEqual(obj.value, "version")
obj.value = "still version"
get_transaction().commit()
transaction.commit()
cn2.close()
db.abortVersion("b")
txn = get_transaction()
txn = transaction.get()
txn.note("abort version b")
txn.commit()
......@@ -524,7 +525,7 @@ class VersionStorage:
L = db.undoInfo()
db.undo(L[0]["id"])
txn = get_transaction()
txn = transaction.get()
txn.note("undo abort")
txn.commit()
......
......@@ -18,6 +18,7 @@
import time
import transaction
from ZODB.FileStorage import FileStorage
from ZODB import DB
......@@ -30,20 +31,20 @@ def create_dangling_ref(db):
rt = db.open().root()
rt[1] = o1 = P()
get_transaction().note("create o1")
get_transaction().commit()
transaction.get().note("create o1")
transaction.commit()
rt[2] = o2 = P()
get_transaction().note("create o2")
get_transaction().commit()
transaction.get().note("create o2")
transaction.commit()
c = o1.child = P()
get_transaction().note("set child on o1")
get_transaction().commit()
transaction.get().note("set child on o1")
transaction.commit()
o1.child = P()
get_transaction().note("replace child on o1")
get_transaction().commit()
transaction.get().note("replace child on o1")
transaction.commit()
time.sleep(2)
# The pack should remove the reference to c, because it is no
......@@ -53,8 +54,8 @@ def create_dangling_ref(db):
print repr(c._p_oid)
o2.child = c
get_transaction().note("set child on o2")
get_transaction().commit()
transaction.get().note("set child on o2")
transaction.commit()
def main():
fs = FileStorage("dangle.fs")
......
......@@ -40,6 +40,7 @@ sys.path.insert(0, os.getcwd())
import ZODB, ZODB.FileStorage
import persistent
import transaction
class P(persistent.Persistent): pass
......@@ -85,7 +86,7 @@ def main(args):
for r in 1, 10, 100, 1000:
t=time.time()
jar=db.open()
get_transaction().begin()
transaction.begin()
rt=jar.root()
key='s%s' % r
if rt.has_key(key): p=rt[key]
......@@ -96,7 +97,7 @@ def main(args):
v=getattr(p, str(i), P())
v.d=d
setattr(p,str(i),v)
get_transaction().commit()
transaction.commit()
jar.close()
t=time.time()-t
if detailed:
......
......@@ -13,13 +13,13 @@
##############################################################################
"""Test broken-object suppport
$Id: testBroken.py,v 1.3 2004/03/04 22:41:53 jim Exp $
$Id: testBroken.py,v 1.4 2004/04/16 15:58:11 jeremy Exp $
"""
import sys
import unittest
import persistent
#from transaction import get_transaction
import transaction
from doctest import DocTestSuite
from ZODB.tests.util import DB
......@@ -46,7 +46,7 @@ def test_integration():
>>> a.x = 1
>>> conn1 = db.open()
>>> conn1.root()['a'] = a
>>> get_transaction().commit()
>>> transaction.commit()
>>> conn2 = db.open()
>>> a2 = conn2.root()['a']
......
......@@ -22,10 +22,11 @@ import gc
import time
import unittest
import ZODB
import ZODB.MappingStorage
from persistent.cPickleCache import PickleCache
from persistent.mapping import PersistentMapping
import transaction
import ZODB
import ZODB.MappingStorage
from ZODB.tests.MinPO import MinPO
from ZODB.utils import p64
......@@ -60,14 +61,14 @@ class CacheTestBase(unittest.TestCase):
d = r.get(i)
if d is None:
d = r[i] = PersistentMapping()
get_transaction().commit()
transaction.commit()
for i in range(15):
o = d.get(i)
if o is None:
o = d[i] = MinPO(i)
o.value += 1
get_transaction().commit()
transaction.commit()
class DBMethods(CacheTestBase):
......@@ -145,7 +146,7 @@ class LRUCacheTests(CacheTestBase):
for t in range(5):
for i in range(dataset_size):
l[(t,i)] = r[i] = MinPO(i)
get_transaction().commit()
transaction.commit()
# commit() will register the objects, placing them in the
# cache. at the end of commit, the cache will be reduced
# down to CACHE_SIZE items
......
......@@ -15,6 +15,7 @@
import tempfile
import unittest
import transaction
import ZODB.config
from ZODB.POSException import ReadOnlyError
......@@ -34,7 +35,7 @@ class ConfigTestBase(unittest.TestCase):
cn = db.open()
rt = cn.root()
rt["test"] = 1
get_transaction().commit()
transaction.commit()
db.close()
......
......@@ -18,10 +18,10 @@ import unittest
import warnings
from persistent import Persistent
import transaction
from ZODB.config import databaseFromString
from ZODB.utils import p64, u64
from ZODB.tests.warnhook import WarningsHook
import transaction
class ConnectionDotAdd(unittest.TestCase):
......@@ -397,7 +397,7 @@ class InvalidationTests(unittest.TestCase):
>>> p3 = Persistent()
>>> r = cn.root()
>>> r.update(dict(p1=p1, p2=p2, p3=p3))
>>> get_transaction().commit()
>>> transaction.commit()
Transaction ids are 8-byte strings, just like oids; p64() will
create one from an int.
......
......@@ -16,6 +16,8 @@ import time
import unittest
import warnings
import transaction
import ZODB
import ZODB.FileStorage
......@@ -38,10 +40,10 @@ class DBTests(unittest.TestCase):
c = self.db.open(version)
r = c.root()
o = r[time.time()] = MinPO(0)
get_transaction().commit()
transaction.commit()
for i in range(25):
o.value = MinPO(i)
get_transaction().commit()
transaction.commit()
o = o.value
c.close()
......
......@@ -22,9 +22,10 @@ old code, developers will have a hard time testing the new code.
import unittest
import transaction
from transaction import Transaction
import ZODB
from ZODB.MappingStorage import MappingStorage
from transaction import Transaction
import cPickle
import cStringIO
import sys
......@@ -59,7 +60,7 @@ class PMTests(unittest.TestCase):
r[1] = 1
r[2] = 2
r[3] = r
get_transaction().commit()
transaction.commit()
# MappingStorage stores serialno + pickle in its _index.
root_pickle = s._index['\000' * 8][8:]
......
......@@ -26,6 +26,7 @@ from ZODB.FileStorage import FileStorage
from ZODB.fsrecover import recover
from persistent.mapping import PersistentMapping
import transaction
class RecoverTest(unittest.TestCase):
......@@ -58,10 +59,10 @@ class RecoverTest(unittest.TestCase):
# looks like a Data.fs > 1MB
for i in range(50):
d = rt[i] = PersistentMapping()
get_transaction().commit()
transaction.commit()
for j in range(50):
d[j] = "a" * j
get_transaction().commit()
transaction.commit()
def damage(self, num, size):
self.storage.close()
......
......@@ -43,14 +43,14 @@ class ZODBTests(unittest.TestCase):
self._db = ZODB.DB(self._storage)
def populate(self):
get_transaction().begin()
transaction.begin()
conn = self._db.open()
root = conn.root()
root['test'] = pm = PersistentMapping()
for n in range(100):
pm[n] = PersistentMapping({0: 100 - n})
get_transaction().note('created test data')
get_transaction().commit()
transaction.get().note('created test data')
transaction.commit()
conn.close()
def tearDown(self):
......@@ -71,8 +71,8 @@ class ZODBTests(unittest.TestCase):
conn.close()
def duplicate(self, conn, abort_it):
get_transaction().begin()
get_transaction().note('duplication')
transaction.begin()
transaction.get().note('duplication')
root = conn.root()
ob = root['test']
assert len(ob) > 10, 'Insufficient test data'
......@@ -87,15 +87,15 @@ class ZODBTests(unittest.TestCase):
root['dup'] = new_ob
f.close()
if abort_it:
get_transaction().abort()
transaction.abort()
else:
get_transaction().commit()
transaction.commit()
except:
get_transaction().abort()
transaction.abort()
raise
def verify(self, conn, abort_it):
get_transaction().begin()
transaction.begin()
root = conn.root()
ob = root['test']
try:
......@@ -123,7 +123,7 @@ class ZODBTests(unittest.TestCase):
for v in ob2.values():
assert not oids.has_key(v._p_oid), (
'Did not fully separate duplicate from original')
get_transaction().commit()
transaction.commit()
def checkExportImportAborted(self):
self.checkExportImport(abort_it=True)
......@@ -136,11 +136,11 @@ class ZODBTests(unittest.TestCase):
try:
r = conn.root()
r[1] = 1
get_transaction().commit()
transaction.commit()
finally:
conn.close()
self._db.abortVersion("version")
get_transaction().commit()
transaction.commit()
def checkResetCache(self):
# The cache size after a reset should be 0. Note that
......@@ -302,7 +302,7 @@ class ZODBTests(unittest.TestCase):
real_data["b"] = PersistentMapping({"indexed_value": 1})
index[1] = PersistentMapping({"b": 1})
index[0] = PersistentMapping({"a": 1})
get_transaction().commit()
transaction.commit()
# load some objects from one connection
tm = transaction.TransactionManager()
......@@ -314,7 +314,7 @@ class ZODBTests(unittest.TestCase):
real_data["b"]["indexed_value"] = 0
del index[1]["b"]
index[0]["b"] = 1
get_transaction().commit()
transaction.commit()
del real_data2["a"]
try:
......@@ -334,7 +334,7 @@ class ZODBTests(unittest.TestCase):
self.assert_(not index2[1]._p_changed)
self.assertRaises(ConflictError, tm.get().commit)
get_transaction().abort()
transaction.abort()
def checkIndependent(self):
self.obj = Independent()
......
......@@ -16,6 +16,7 @@
import doctest
from persistent import Persistent
import transaction
from ZODB.config import databaseFromString
class RecalcitrantObject(Persistent):
......@@ -67,7 +68,7 @@ class CacheTests:
... o = RegularObject()
... L.append(o)
... r[i] = o
>>> get_transaction().commit()
>>> transaction.commit()
After committing a transaction and calling cacheGC(), there
should be cache-size (4) objects in the cache. One of the
......@@ -137,7 +138,7 @@ class CacheTests:
... o = RecalcitrantObject()
... L.append(o)
... r[i] = o
>>> get_transaction().commit()
>>> transaction.commit()
>>> [o._p_state for o in L]
[0, 0, 0, 0, 0]
......@@ -174,7 +175,7 @@ class CacheTests:
... o = RegularObject()
... L.append(o)
... r[i] = o
>>> get_transaction().commit()
>>> transaction.commit()
>>> RegularObject.deactivations
1
......@@ -188,7 +189,7 @@ class CacheTests:
>>> cn._cache.ringlen()
5
>>> get_transaction().abort()
>>> transaction.abort()
>>> cn._cache.ringlen()
2
>>> RegularObject.deactivations
......
......@@ -13,11 +13,12 @@
##############################################################################
"""Conventience function for creating test databases
$Id: util.py,v 1.3 2004/02/19 18:24:00 jeremy Exp $
$Id: util.py,v 1.4 2004/04/16 15:58:11 jeremy Exp $
"""
import time
import persistent
import transaction
from ZODB.MappingStorage import MappingStorage
from ZODB.DB import DB as _DB
try:
......@@ -29,7 +30,7 @@ def DB(name='Test'):
return _DB(MappingStorage(name))
def commit():
get_transaction().commit()
transaction.commit()
def pack(db):
db.pack(time.time()+1)
......
......@@ -16,7 +16,7 @@
from ZODB.POSException import ReadConflictError, ConflictError
def _commit(note):
t = get_transaction()
t = transaction.get()
if note:
t.note(note)
t.commit()
......@@ -42,14 +42,14 @@ def transact(f, note=None, retries=5):
try:
r = f(*args, **kwargs)
except ReadConflictError, msg:
get_transaction().abort()
transaction.abort()
if not n:
raise
continue
try:
_commit(note)
except ConflictError, msg:
get_transaction().abort()
transaction.abort()
if not n:
raise
continue
......
......@@ -16,14 +16,11 @@
This module tests and documents, through example, overriding attribute
access methods.
$Id: test_overriding_attrs.py,v 1.5 2004/03/04 22:41:59 jim Exp $
$Id: test_overriding_attrs.py,v 1.6 2004/04/16 15:58:10 jeremy Exp $
"""
from persistent import Persistent
try:
from transaction import get_transaction
except ImportError:
pass # else assume ZODB will install it as a builtin
import transaction
from ZODB.tests.util import DB
class SampleOverridingGetattr(Persistent):
......@@ -58,7 +55,7 @@ class SampleOverridingGetattr(Persistent):
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> get_transaction().commit()
>>> transaction.commit()
>>> o._p_deactivate()
>>> o._p_changed
......@@ -124,7 +121,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> get_transaction().commit()
>>> transaction.commit()
>>> o._p_deactivate()
>>> o._p_changed
......@@ -229,7 +226,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> get_transaction().commit()
>>> transaction.commit()
>>> o._p_deactivate()
>>> o._p_changed
......@@ -247,7 +244,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
Now, if commit:
>>> get_transaction().commit()
>>> transaction.commit()
>>> o._p_changed
0
......@@ -329,7 +326,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
>>> db = DB()
>>> conn = db.open()
>>> conn.root()['o'] = o
>>> get_transaction().commit()
>>> transaction.commit()
>>> o._p_deactivate()
>>> o._p_changed
......@@ -352,7 +349,7 @@ class SampleOverridingGetattributeSetattrAndDelattr(Persistent):
Now, if commit:
>>> get_transaction().commit()
>>> transaction.commit()
>>> o._p_changed
0
......
......@@ -66,7 +66,7 @@ def check_server(addr, storage, write):
monitor = root['monitor'] = PersistentMapping()
obj = monitor['zeoup'] = monitor.get('zeoup', MinPO(0))
obj.value += 1
get_transaction().commit()
transaction.commit()
except ConflictError:
pass
cn.close()
......
......@@ -89,7 +89,7 @@ Usage: loadmail2 [options]
Specify the mailbox for getting input data.
$Id: zodbload.py,v 1.5 2004/03/18 13:27:49 yuppie Exp $
$Id: zodbload.py,v 1.6 2004/04/16 15:58:10 jeremy Exp $
"""
import mailbox
......@@ -217,7 +217,7 @@ def setup(lib_python):
app.cat.addIndex('PrincipiaSearchSource', 'ZCTextIndex', extra)
get_transaction().commit()
transaction.commit()
system = AccessControl.SpecialUsers.system
AccessControl.SecurityManagement.newSecurityManager(None, system)
......@@ -237,7 +237,7 @@ def do(db, f, args):
while 1:
connection = db.open()
try:
get_transaction().begin()
transaction.begin()
t=time.time()
c=time.clock()
try:
......@@ -245,7 +245,7 @@ def do(db, f, args):
r = f(connection, *args)
except ConflictError:
rconflicts += 1
get_transaction().abort()
transaction.abort()
continue
finally:
wcomp += time.time() - t
......@@ -255,11 +255,11 @@ def do(db, f, args):
c=time.clock()
try:
try:
get_transaction().commit()
transaction.commit()
break
except ConflictError:
wconflicts += 1
get_transaction().abort()
transaction.abort()
continue
finally:
wcommit += time.time() - t
......
......@@ -36,7 +36,7 @@ TODO
add in tests for objects which are modified multiple times,
for example an object that gets modified in multiple sub txns.
$Id: test_transaction.py,v 1.1 2004/04/16 00:19:38 jeremy Exp $
$Id: test_transaction.py,v 1.2 2004/04/16 15:58:10 jeremy Exp $
"""
import unittest
......@@ -64,7 +64,7 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify()
self.sub2.modify()
get_transaction().commit()
transaction.commit()
assert self.sub1._p_jar.ccommit_sub == 0
assert self.sub1._p_jar.ctpc_finish == 1
......@@ -74,13 +74,13 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify()
self.sub2.modify()
get_transaction().abort()
transaction.abort()
assert self.sub2._p_jar.cabort == 1
def testTransactionNote(self):
t = get_transaction()
t = transaction.get()
t.note('This is a note.')
self.assertEqual(t.description, 'This is a note.')
......@@ -94,12 +94,12 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify()
self.sub2.modify()
get_transaction().commit(1)
transaction.commit(1)
assert self.sub1._p_jar.ctpc_vote == 0
assert self.sub1._p_jar.ctpc_finish == 1
get_transaction().commit()
transaction.commit()
assert self.sub1._p_jar.ccommit_sub == 1
assert self.sub1._p_jar.ctpc_vote == 1
......@@ -109,8 +109,8 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify()
self.sub2.modify()
get_transaction().commit(1)
get_transaction().abort()
transaction.commit(1)
transaction.abort()
assert self.sub1._p_jar.ctpc_vote == 0
assert self.sub1._p_jar.cabort == 0
......@@ -118,12 +118,12 @@ class TransactionTests(unittest.TestCase):
def testMultipleSubTransactionCommitCommit(self):
self.sub1.modify()
get_transaction().commit(1)
transaction.commit(1)
self.sub2.modify()
# reset a flag on the original to test it again
self.sub1.ctpc_finish = 0
get_transaction().commit(1)
transaction.commit(1)
# this is interesting.. we go through
# every subtrans commit with all subtrans capable
......@@ -135,7 +135,7 @@ class TransactionTests(unittest.TestCase):
# add another before we do the entire txn commit
self.sub3.modify()
get_transaction().commit()
transaction.commit()
# we did an implicit sub commit, is this impl artifact?
assert self.sub3._p_jar.ccommit_sub == 1
......@@ -161,12 +161,12 @@ class TransactionTests(unittest.TestCase):
# add it
self.sub1.modify()
get_transaction().commit(1)
transaction.commit(1)
# add another
self.sub2.modify()
get_transaction().commit(1)
transaction.commit(1)
assert self.sub1._p_jar.ctpc_vote == 0
assert self.sub1._p_jar.ctpc_finish > 0
......@@ -175,10 +175,10 @@ class TransactionTests(unittest.TestCase):
self.sub3.modify()
# abort the sub transaction
get_transaction().abort(1)
transaction.abort(1)
# commit the container transaction
get_transaction().commit()
transaction.commit()
assert self.sub3._p_jar.cabort == 1
assert self.sub1._p_jar.ccommit_sub == 1
......@@ -190,7 +190,7 @@ class TransactionTests(unittest.TestCase):
self.nosub1.modify()
get_transaction().commit()
transaction.commit()
assert self.nosub1._p_jar.ctpc_finish == 1
......@@ -198,7 +198,7 @@ class TransactionTests(unittest.TestCase):
self.nosub1.modify()
get_transaction().abort()
transaction.abort()
assert self.nosub1._p_jar.ctpc_finish == 0
assert self.nosub1._p_jar.cabort == 1
......@@ -222,7 +222,7 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify(tracing='sub')
self.nosub1.modify(tracing='nosub')
get_transaction().commit(1)
transaction.commit(1)
assert self.sub1._p_jar.ctpc_finish == 1
......@@ -230,7 +230,7 @@ class TransactionTests(unittest.TestCase):
# in a subtrans
assert self.nosub1._p_jar.ctpc_finish == 0
get_transaction().abort()
transaction.abort()
assert self.nosub1._p_jar.cabort == 1
assert self.sub1._p_jar.cabort_sub == 1
......@@ -240,11 +240,11 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify()
self.nosub1.modify()
get_transaction().commit(1)
transaction.commit(1)
assert self.nosub1._p_jar.ctpc_vote == 0
get_transaction().commit()
transaction.commit()
#assert self.nosub1._p_jar.ccommit_sub == 0
assert self.nosub1._p_jar.ctpc_vote == 1
......@@ -277,12 +277,12 @@ class TransactionTests(unittest.TestCase):
# add it
self.sub1.modify()
get_transaction().commit(1)
transaction.commit(1)
# add another
self.nosub1.modify()
get_transaction().commit(1)
transaction.commit(1)
assert self.sub1._p_jar.ctpc_vote == 0
assert self.nosub1._p_jar.ctpc_vote == 0
......@@ -292,7 +292,7 @@ class TransactionTests(unittest.TestCase):
self.sub2.modify()
# commit the container transaction
get_transaction().commit()
transaction.commit()
# we did an implicit sub commit
assert self.sub2._p_jar.ccommit_sub == 1
......@@ -317,7 +317,7 @@ class TransactionTests(unittest.TestCase):
self.sub2.modify()
try:
get_transaction().abort()
transaction.abort()
except TestTxnException: pass
assert self.nosub1._p_jar.cabort == 1
......@@ -331,7 +331,7 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify(nojar=1)
try:
get_transaction().commit()
transaction.commit()
except TestTxnException: pass
assert self.nosub1._p_jar.ctpc_finish == 0
......@@ -346,7 +346,7 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify(nojar=1)
try:
get_transaction().commit()
transaction.commit()
except TestTxnException: pass
assert self.nosub1._p_jar.ctpc_finish == 0
......@@ -372,7 +372,7 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify(nojar=1)
try:
get_transaction().commit()
transaction.commit()
except TestTxnException: pass
assert self.nosub1._p_jar.ctpc_abort == 1
......@@ -386,7 +386,7 @@ class TransactionTests(unittest.TestCase):
self.sub1.modify(nojar=1)
try:
get_transaction().commit()
transaction.commit()
except TestTxnException:
pass
......@@ -403,19 +403,19 @@ class TransactionTests(unittest.TestCase):
# they come out of the dictionary.
self.sub1.modify()
get_transaction().commit(1)
transaction.commit(1)
self.nosub1.modify()
self.sub2._p_jar = SubTransactionJar(errors='commit_sub')
self.sub2.modify(nojar=1)
get_transaction().commit(1)
transaction.commit(1)
self.sub3.modify()
try:
get_transaction().commit()
transaction.commit()
except TestTxnException:
pass
......@@ -442,17 +442,17 @@ class TransactionTests(unittest.TestCase):
self.sub1._p_jar = SubTransactionJar(errors='commit_sub')
self.sub1.modify(nojar=1)
get_transaction().commit(1)
transaction.commit(1)
self.nosub1.modify()
self.sub2._p_jar = SubTransactionJar(errors='abort_sub')
self.sub2.modify(nojar=1)
get_transaction().commit(1)
transaction.commit(1)
self.sub3.modify()
try:
get_transaction().commit()
transaction.commit()
except TestTxnException, err:
pass
else:
......@@ -483,7 +483,7 @@ class TransactionTests(unittest.TestCase):
## obj.modify(nojar=1)
## try:
## get_transaction().commit()
## transaction.commit()
## except TestTxnException:
## pass
......@@ -492,7 +492,7 @@ class TransactionTests(unittest.TestCase):
## self.sub2.modify()
## try:
## get_transaction().commit()
## transaction.commit()
## except Transaction.POSException.TransactionError:
## pass
## else:
......@@ -511,7 +511,7 @@ class DataObject:
self._p_jar = NoSubTransactionJar(tracing=tracing)
else:
self._p_jar = SubTransactionJar(tracing=tracing)
get_transaction().register(self)
transaction.get().register(self)
class TestTxnException(Exception):
pass
......
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