Commit 56dd41ff authored by Tim Peters's avatar Tim Peters

Rewrite more instances of the deprecated Transaction_object.begin().

Caution:  Since no deprecation warnings about Transaction.begin()
were raised by the test suite before this patch, none of this code
is exercised by the test suite -- or it is, but "something"
suppresses the deprecation warnings.  So it's hard to claim that
this patch has been tested; the strongest claim I can make is that
all the unit tests still pass.
parent 61a84033
...@@ -17,6 +17,7 @@ $Id$ ...@@ -17,6 +17,7 @@ $Id$
import os, sys import os, sys
from time import time from time import time
import transaction
import Products import Products
from ExtensionClass import Base from ExtensionClass import Base
from Globals import PersistentMapping from Globals import PersistentMapping
...@@ -321,7 +322,7 @@ def autoRefresh(jar): ...@@ -321,7 +322,7 @@ def autoRefresh(jar):
Connection.resetCaches() Connection.resetCaches()
get_transaction().commit() get_transaction().commit()
jar._resetCache() jar._resetCache()
get_transaction().begin() transaction.begin()
def setupAutoRefresh(jar): def setupAutoRefresh(jar):
# Install hook. # Install hook.
......
...@@ -19,6 +19,7 @@ import unittest ...@@ -19,6 +19,7 @@ import unittest
import utils import utils
import profiler import profiler
import transaction
from AccessControl import getSecurityManager from AccessControl import getSecurityManager
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
from AccessControl.SecurityManagement import noSecurityManager from AccessControl.SecurityManagement import noSecurityManager
...@@ -85,7 +86,7 @@ class ZopeTestCase(profiler.Profiled, unittest.TestCase): ...@@ -85,7 +86,7 @@ class ZopeTestCase(profiler.Profiled, unittest.TestCase):
at the start of setUp(). By default begins at the start of setUp(). By default begins
a new transaction. a new transaction.
''' '''
get_transaction().begin() transaction.begin()
def beforeClose(self): def beforeClose(self):
'''Called before the ZODB connection is closed, '''Called before the ZODB connection is closed,
......
...@@ -15,6 +15,7 @@ import os, sys ...@@ -15,6 +15,7 @@ import os, sys
if __name__ == '__main__': if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py')) execfile(os.path.join(sys.path[0], 'framework.py'))
import transaction
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Acquisition import aq_base from Acquisition import aq_base
...@@ -69,7 +70,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase): ...@@ -69,7 +70,7 @@ class TestPortalTestCase(ZopeTestCase.PortalTestCase):
# with an empty fixture. # with an empty fixture.
self._called = [] self._called = []
# Implicitly aborts previous transaction # Implicitly aborts previous transaction
get_transaction().begin() transaction.begin()
def beforeSetUp(self): def beforeSetUp(self):
self._called.append('beforeSetUp') self._called.append('beforeSetUp')
......
...@@ -15,6 +15,7 @@ import os, sys ...@@ -15,6 +15,7 @@ import os, sys
if __name__ == '__main__': if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py')) execfile(os.path.join(sys.path[0], 'framework.py'))
import transaction
from Testing import ZopeTestCase from Testing import ZopeTestCase
from Acquisition import aq_base from Acquisition import aq_base
...@@ -44,7 +45,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase): ...@@ -44,7 +45,7 @@ class TestZopeTestCase(ZopeTestCase.ZopeTestCase):
# with an empty fixture. # with an empty fixture.
self._called = [] self._called = []
# Implicitly aborts previous transaction # Implicitly aborts previous transaction
get_transaction().begin() transaction.begin()
def beforeSetUp(self): def beforeSetUp(self):
self._called.append('beforeSetUp') self._called.append('beforeSetUp')
......
...@@ -15,6 +15,7 @@ __doc__="""Python Object Publisher -- Publish Python objects on web servers ...@@ -15,6 +15,7 @@ __doc__="""Python Object Publisher -- Publish Python objects on web servers
$Id$""" $Id$"""
import sys, os import sys, os
import transaction
from Response import Response from Response import Response
from Request import Request from Request import Request
from maybe_lock import allocate_lock from maybe_lock import allocate_lock
...@@ -298,9 +299,12 @@ def get_module_info(module_name, modules={}, ...@@ -298,9 +299,12 @@ def get_module_info(module_name, modules={},
class DefaultTransactionsManager: class DefaultTransactionsManager:
def begin(self): get_transaction().begin() def begin(self):
def commit(self): get_transaction().commit() transaction.begin()
def abort(self): get_transaction().abort() def commit(self):
get_transaction().commit()
def abort(self):
get_transaction().abort()
def recordMetaData(self, object, request): def recordMetaData(self, object, request):
# Is this code needed? # Is this code needed?
request_get = request.get request_get = request.get
......
...@@ -22,6 +22,7 @@ from types import StringType, ListType ...@@ -22,6 +22,7 @@ from types import StringType, ListType
from zExceptions import Unauthorized from zExceptions import Unauthorized
from zLOG import LOG, WARNING, INFO, BLATHER, log_time from zLOG import LOG, WARNING, INFO, BLATHER, log_time
from ZODB.POSException import ConflictError from ZODB.POSException import ConflictError
import transaction
import AccessControl.User import AccessControl.User
import App.FindHomes import App.FindHomes
import ExtensionClass import ExtensionClass
...@@ -213,8 +214,8 @@ def zpublisher_exception_hook(published, REQUEST, t, v, traceback): ...@@ -213,8 +214,8 @@ def zpublisher_exception_hook(published, REQUEST, t, v, traceback):
class TransactionsManager: class TransactionsManager:
def begin(self, def begin(self,
# Optimize global var lookups: # Optimize global var lookups:
get_transaction=get_transaction): transaction=transaction):
get_transaction().begin() transaction.begin()
def commit(self, def commit(self,
# Optimize global var lookups: # Optimize global var lookups:
......
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