Skip to content
This repository has been archived by the owner on May 13, 2020. It is now read-only.

Commit

Permalink
__builtin__.get_transaction() is officially deprecated in ZODB 3.4.
Browse files Browse the repository at this point in the history
Got rid of it in the Zope source.  The remaining instances are in
code stitched in from ZODB.  Those will go away by magic when
ZODB 3.4 gets stitched in.
  • Loading branch information
Tim Peters committed Mar 28, 2005
1 parent b37f80e commit 2d1508b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 16 deletions.
7 changes: 4 additions & 3 deletions tests/indexhtml.py
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions tests/mailtest.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 2 additions & 1 deletion tests/mhindex.py
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 8 additions & 6 deletions tests/testIndex.py
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand All @@ -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())
Expand All @@ -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']
Expand All @@ -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):

Expand Down
7 changes: 4 additions & 3 deletions tests/testLexicon.py
Expand Up @@ -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
Expand Down Expand Up @@ -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']
Expand All @@ -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))

Expand Down

0 comments on commit 2d1508b

Please sign in to comment.