diff --git a/tests/indexhtml.py b/tests/indexhtml.py
index e5989e9..7e04bb4 100644
--- a/tests/indexhtml.py
+++ b/tests/indexhtml.py
@@ -16,6 +16,7 @@
import ZODB
from ZODB.FileStorage import FileStorage
from BTrees.IOBTree import IOBTree
+import transaction
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
from Products.ZCTextIndex.HTMLSplitter import HTMLWordSplitter
@@ -58,7 +59,7 @@ def make_old_index():
def main(db, root, dir):
rt["index"] = index = INDEX()
rt["files"] = paths = IOBTree()
- get_transaction().commit()
+ transaction.commit()
zodb_time = 0.0
pack_time = 0.0
@@ -83,7 +84,7 @@ def main(db, root, dir):
f.close()
if docid % TXN_INTERVAL == 0:
z0 = clock()
- get_transaction().commit()
+ transaction.commit()
z1 = clock()
zodb_time += z1 - z0
if VERBOSE:
@@ -97,7 +98,7 @@ def main(db, root, dir):
if VERBOSE:
print "pack took", p1 - p0, pack_time
z0 = clock()
- get_transaction().commit()
+ transaction.commit()
z1 = t1 = clock()
total_time = t1 - t0
zodb_time += z1 - z0
diff --git a/tests/mailtest.py b/tests/mailtest.py
index e8852d1..b415eef 100644
--- a/tests/mailtest.py
+++ b/tests/mailtest.py
@@ -42,6 +42,7 @@
import ZODB
import ZODB.FileStorage
+import transaction
from Products.ZCTextIndex.Lexicon import \
Lexicon, CaseNormalizer, Splitter, StopWordRemover
from Products.ZCTextIndex.ZCTextIndex import ZCTextIndex
@@ -92,7 +93,7 @@ def index(rt, mboxfile, db, profiler):
rt["documents"] = docs = IOBTree()
else:
docs = None
- get_transaction().commit()
+ transaction.commit()
mbox = mailbox.UnixMailbox(open(mboxfile, 'rb'))
if VERBOSE:
@@ -107,7 +108,7 @@ def index(rt, mboxfile, db, profiler):
idx_time += itime
pack_time += ptime
- get_transaction().commit()
+ transaction.commit()
if PACK_INTERVAL and i % PACK_INTERVAL != 0:
if VERBOSE >= 2:
@@ -148,7 +149,7 @@ def indexmbox(mbox, idx, docs, db):
if not EXCLUDE_TEXT:
docs[i] = msg
if i % TXN_SIZE == 0:
- get_transaction().commit()
+ transaction.commit()
i1 = time.clock()
idx_time += i1 - i0
if VERBOSE and i % 50 == 0:
diff --git a/tests/mhindex.py b/tests/mhindex.py
index d8cbf01..9806d70 100644
--- a/tests/mhindex.py
+++ b/tests/mhindex.py
@@ -51,6 +51,7 @@
from BTrees.IOBTree import IOBTree
from BTrees.OIBTree import OIBTree
from BTrees.IIBTree import IIBTree
+import transaction
from Products.ZCTextIndex.NBest import NBest
from Products.ZCTextIndex.OkapiIndex import OkapiIndex
@@ -552,7 +553,7 @@ def maycommit(self):
def commit(self):
if self.trans_count > 0:
print "committing..."
- get_transaction().commit()
+ transaction.commit()
self.trans_count = 0
self.pack_count += 1
if self.pack_count >= self.pack_limit > 0:
diff --git a/tests/testIndex.py b/tests/testIndex.py
index 43adc2b..e9d9091 100644
--- a/tests/testIndex.py
+++ b/tests/testIndex.py
@@ -15,6 +15,8 @@
import os
from unittest import TestCase, TestSuite, main, makeSuite
+import transaction
+
from BTrees.Length import Length
from Products.ZCTextIndex.Lexicon import Lexicon, Splitter
from Products.ZCTextIndex.CosineIndex import CosineIndex
@@ -178,7 +180,7 @@ def test_index_doc_conflict(self):
self.openDB()
r1 = self.db.open().root()
r1['i'] = self.index
- get_transaction().commit()
+ transaction.commit()
r2 = self.db.open().root()
copy = r2['i']
@@ -192,10 +194,10 @@ def test_index_doc_conflict(self):
self.assertEqual(self.index._p_serial, copy._p_serial)
self.index.index_doc(0, 'The time has come')
- get_transaction().commit()
+ transaction.commit()
copy.index_doc(1, 'That time has gone')
- get_transaction().commit()
+ transaction.commit()
def test_reindex_doc_conflict(self):
self.index = OkapiIndex(Lexicon())
@@ -204,7 +206,7 @@ def test_reindex_doc_conflict(self):
self.openDB()
r1 = self.db.open().root()
r1['i'] = self.index
- get_transaction().commit()
+ transaction.commit()
r2 = self.db.open().root()
copy = r2['i']
@@ -218,10 +220,10 @@ def test_reindex_doc_conflict(self):
self.assertEqual(self.index._p_serial, copy._p_serial)
self.index.index_doc(0, 'Sometimes change isn\'t bad')
- get_transaction().commit()
+ transaction.commit()
copy.index_doc(1, 'Then again, who asked you?')
- get_transaction().commit()
+ transaction.commit()
class TestUpgrade(TestCase):
diff --git a/tests/testLexicon.py b/tests/testLexicon.py
index 086cb92..bdfb0ee 100644
--- a/tests/testLexicon.py
+++ b/tests/testLexicon.py
@@ -16,6 +16,7 @@
from unittest import TestCase, TestSuite, main, makeSuite
import ZODB
+import transaction
from Products.ZCTextIndex.Lexicon import Lexicon
from Products.ZCTextIndex.Lexicon import Splitter, CaseNormalizer
@@ -165,7 +166,7 @@ def testAddWordConflict(self):
self.openDB()
r1 = self.db.open().root()
r1['l'] = self.l
- get_transaction().commit()
+ transaction.commit()
r2 = self.db.open().root()
copy = r2['l']
@@ -177,11 +178,11 @@ def testAddWordConflict(self):
self.assertEqual(self.l._p_serial, copy._p_serial)
self.l.sourceToWordIds('mary had a little lamb')
- get_transaction().commit()
+ transaction.commit()
copy.sourceToWordIds('whose fleece was')
copy.sourceToWordIds('white as snow')
- get_transaction().commit()
+ transaction.commit()
self.assertEqual(copy.length(), 11)
self.assertEqual(copy.length(), len(copy._words))