Commit 643b9893 authored by Tim Peters's avatar Tim Peters

Changes for ZODB 3.3:

1. a_Transaction_object.begin() is deprecated.  Don't use it.

2. Commit failure is "sticky" now:  the current transaction
   must be explicitly discarded (abort() or begin()) before
   a commit can succeed again.
parent 8aef2341
......@@ -18,6 +18,7 @@ $Id$
import unittest
import ZODB
import transaction
from Acquisition import Implicit
from AccessControl import ClassSecurityInfo
from Globals import InitializeClass
......@@ -95,7 +96,7 @@ class TestBindings(unittest.TestCase):
def setUp(self):
from Testing.ZODButil import makeDB
get_transaction().begin()
transaction.begin()
self.db = makeDB()
self.connection = self.db.open()
......
......@@ -20,6 +20,8 @@ import os, sys, base64, unittest
from Testing.makerequest import makerequest
import transaction
import Zope
Zope.startup()
......@@ -33,7 +35,7 @@ from AccessControl.User import User
class UserFolderTests(unittest.TestCase):
def setUp(self):
get_transaction().begin()
transaction.begin()
self.app = makerequest(Zope.app())
try:
# Set up a user and role
......
......@@ -3,6 +3,7 @@ import cStringIO
from mimetools import Message
from multifile import MultiFile
import transaction
from AccessControl import SecurityManager
from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager
......@@ -90,7 +91,7 @@ class CopySupportTestBase(unittest.TestCase):
except:
self.connection.close()
raise
get_transaction().begin()
transaction.begin()
return self.app._getOb( 'folder1' ), self.app._getOb( 'folder2' )
......
......@@ -12,6 +12,7 @@ from ZPublisher.HTTPResponse import HTTPResponse
from App.Common import rfc1123_date
from Testing.makerequest import makerequest
from zExceptions import Redirect
import transaction
try:
here = os.path.dirname(os.path.abspath(__file__))
......@@ -99,7 +100,7 @@ class FileTests(unittest.TestCase):
except:
self.connection.close()
raise
get_transaction().begin()
transaction.begin()
self.file = getattr( self.app, 'file' )
def tearDown( self ):
......
......@@ -15,7 +15,7 @@
import os, sys, unittest
import string, cStringIO, re
import ZODB, Acquisition
import ZODB, Acquisition, transaction
from Acquisition import aq_base
from OFS.Application import Application
from OFS.Folder import manage_addFolder
......@@ -141,7 +141,7 @@ class TestTraverse( unittest.TestCase ):
except:
self.connection.close()
raise
get_transaction().begin()
transaction.begin()
self.folder1 = getattr( self.app, 'folder1' )
self.policy = UnitTestSecurityPolicy()
......
......@@ -15,13 +15,15 @@ from Testing.makerequest import makerequest
import Zope
Zope.startup()
import transaction
import unittest
class VHMRegressions(unittest.TestCase):
def setUp(self):
get_transaction().begin()
transaction.begin()
self.app = makerequest(Zope.app())
try:
self.app.manage_addProduct['SiteAccess'].manage_addVirtualHostMonster('VHM')
......
......@@ -10,6 +10,8 @@ from Testing.makerequest import makerequest
import Zope
Zope.startup()
import transaction
import sys
import unittest
......@@ -17,7 +19,7 @@ import unittest
class SiteErrorLogTests(unittest.TestCase):
def setUp(self):
get_transaction().begin()
transaction.begin()
self.app = makerequest(Zope.app())
try:
self.app.manage_addDTMLMethod('doc', '')
......
......@@ -13,8 +13,8 @@ class UncommittableJar:
self.reason = reason
self.time = time.time()
def sort_key(self):
return self.time()
def sortKey(self):
return str(id(self))
def tpc_begin(self, *arg, **kw):
pass
......@@ -25,6 +25,9 @@ class UncommittableJar:
def tpc_vote(self, transaction):
raise PreventTransactionCommit(self.reason)
def abort(*args):
pass
class makeTransactionUncommittable:
"""
- register an uncommittable object with the provided transaction
......
......@@ -16,6 +16,7 @@ if __name__ == "__main__":
sys.path.insert(0, '../../..')
import ZODB
import transaction
from unittest import TestCase, TestSuite, TextTestRunner, makeSuite
from Products.Transience.TransactionHelper import PreventTransactionCommit, \
makeTransactionUncommittable
......@@ -30,6 +31,7 @@ class TestTransactionHelper(TestCase):
def testUncommittable(self):
makeTransactionUncommittable(self.t, "test")
self.assertRaises(PreventTransactionCommit, get_transaction().commit)
transaction.abort()
def test_suite():
suite = makeSuite(TestTransactionHelper, 'test')
......
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