[Zope-Checkins] SVN: Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/ Ported r29693 from the trunk:

Stefan H. Holek stefan at epy.co.at
Tue Mar 29 15:07:16 EST 2005


Log message for revision 29721:
  Ported r29693 from the trunk:
  __builtin__.get_transaction() is officially deprecated in ZODB 3.4.
  

Changed:
  U   Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
  U   Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testBaseTestCase.py
  U   Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testWebserver.py
  U   Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testZODBCompat.py
  U   Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/utils.py
  U   Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py

-=-
Modified: Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/doc/HOWTO.stx
===================================================================
--- Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/doc/HOWTO.stx	2005-03-29 18:11:18 UTC (rev 29720)
+++ Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/doc/HOWTO.stx	2005-03-29 20:07:16 UTC (rev 29721)
@@ -91,11 +91,11 @@
           Hooks for controlling transactions:
 
           - **'beforeSetUp'** is called before the ZODB connection is opened, at the start of setUp. 
-             The default behaviour of this hook is to call 'get_transaction().begin()'. 
+             The default behaviour of this hook is to call 'transaction.begin()'. 
              You will rarely want to override this.
 
           - **'beforeClose'** is called before the ZODB connection is closed, at the end of
-             tearDown. By default this method calls 'get_transaction().abort()' to discard
+             tearDown. By default this method calls 'transaction.abort()' to discard
              any changes made by the test. In some situations you may need to override 
              this hook and commit the transaction instead. Make sure you really know what 
              you are doing though.

Modified: Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testBaseTestCase.py
===================================================================
--- Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testBaseTestCase.py	2005-03-29 18:11:18 UTC (rev 29720)
+++ Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testBaseTestCase.py	2005-03-29 20:07:16 UTC (rev 29721)
@@ -26,6 +26,8 @@
 if __name__ == '__main__':
     execfile(os.path.join(sys.path[0], 'framework.py'))
 
+import transaction
+
 from Testing.ZopeTestCase import base
 from Testing.ZopeTestCase import utils
 
@@ -146,7 +148,7 @@
 
     def getObjectsInTransaction(self):
         # Lets us spy into the transaction
-        t = get_transaction()
+        t = transaction.get()
         if hasattr(t, '_objects'):      # Zope < 2.8
             return t._objects
         elif hasattr(t, '_resources'):  # Zope >= 2.8

Modified: Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testWebserver.py
===================================================================
--- Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testWebserver.py	2005-03-29 18:11:18 UTC (rev 29720)
+++ Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testWebserver.py	2005-03-29 20:07:16 UTC (rev 29721)
@@ -41,6 +41,8 @@
 from AccessControl import Unauthorized
 import urllib
 
+import transaction
+
 # Create the error_log object
 ZopeTestCase.utils.setupSiteErrorLog()
 
@@ -84,11 +86,11 @@
         self.folder.change_title.changeOwnership(manager)
 
         # Commit so the ZServer threads can see the changes
-        get_transaction().commit()
+        transaction.commit()
 
     def beforeClose(self):
         # Commit after cleanup
-        get_transaction().commit()
+        transaction.commit()
 
     def testAccessPublicObject(self):
         # Test access to a public resource
@@ -188,9 +190,9 @@
         # Additionally, it allows us to commit transactions without
         # harming the test ZODB.
         self.folder.foo = 1
-        get_transaction().commit()
+        transaction.commit()
         self.folder.foo = 2
-        get_transaction().commit()
+        transaction.commit()
 
 
 def test_suite():

Modified: Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testZODBCompat.py
===================================================================
--- Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testZODBCompat.py	2005-03-29 18:11:18 UTC (rev 29720)
+++ Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/testZODBCompat.py	2005-03-29 20:07:16 UTC (rev 29721)
@@ -25,6 +25,8 @@
 
 from Testing import ZopeTestCase
 
+import transaction
+
 from AccessControl.Permissions import add_documents_images_and_files
 from AccessControl.Permissions import delete_objects
 import tempfile
@@ -40,7 +42,7 @@
         self.folder.addDTMLMethod('doc', file='foo')
         # _p_oids are None until we commit a subtransaction
         self.assertEqual(self.folder._p_oid, None)
-        get_transaction().commit(1)
+        transaction.commit(1)
         self.failIfEqual(self.folder._p_oid, None)
 
     def testCutPaste(self):
@@ -91,7 +93,7 @@
         self.folder.addDTMLMethod('doc', file='foo')
         # _p_oids are None until we commit a subtransaction
         self.assertEqual(self.folder._p_oid, None)
-        get_transaction().commit(1)
+        transaction.commit(1)
         self.failIfEqual(self.folder._p_oid, None)
 
     def testExport(self):
@@ -169,7 +171,7 @@
 app = ZopeTestCase.app()
 app._setObject('dummy1', DummyObject())
 app._setObject('dummy2', DummyObject())
-get_transaction().commit()
+transaction.commit()
 ZopeTestCase.close(app)
 
 
@@ -306,45 +308,45 @@
     def testTransactionAbort(self):
         self.folder.foo = 1
         self.failUnless(hasattr(self.folder, 'foo'))
-        get_transaction().abort()
+        transaction.abort()
         # The foo attribute is still present
         self.failUnless(hasattr(self.folder, 'foo'))
 
     def testSubTransactionAbort(self):
         self.folder.foo = 1
         self.failUnless(hasattr(self.folder, 'foo'))
-        get_transaction().commit(1)
-        get_transaction().abort()
+        transaction.commit(1)
+        transaction.abort()
         # This time the abort nukes the foo attribute...
         self.failIf(hasattr(self.folder, 'foo'))
 
     def testTransactionAbortPersistent(self):
         self.folder._p_foo = 1
         self.failUnless(hasattr(self.folder, '_p_foo'))
-        get_transaction().abort()
+        transaction.abort()
         # The _p_foo attribute is still present
         self.failUnless(hasattr(self.folder, '_p_foo'))
 
     def testSubTransactionAbortPersistent(self):
         self.folder._p_foo = 1
         self.failUnless(hasattr(self.folder, '_p_foo'))
-        get_transaction().commit(1)
-        get_transaction().abort()
+        transaction.commit(1)
+        transaction.abort()
         # This time the abort nukes the _p_foo attribute...
         self.failIf(hasattr(self.folder, '_p_foo'))
 
     def testTransactionAbortVolatile(self):
         self.folder._v_foo = 1
         self.failUnless(hasattr(self.folder, '_v_foo'))
-        get_transaction().abort()
+        transaction.abort()
         # The _v_foo attribute is still present
         self.failUnless(hasattr(self.folder, '_v_foo'))
 
     def testSubTransactionAbortVolatile(self):
         self.folder._v_foo = 1
         self.failUnless(hasattr(self.folder, '_v_foo'))
-        get_transaction().commit(1)
-        get_transaction().abort()
+        transaction.commit(1)
+        transaction.abort()
         # This time the abort nukes the _v_foo attribute...
         self.failIf(hasattr(self.folder, '_v_foo'))
 

Modified: Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/utils.py
===================================================================
--- Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/utils.py	2005-03-29 18:11:18 UTC (rev 29720)
+++ Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/utils.py	2005-03-29 20:07:16 UTC (rev 29721)
@@ -18,6 +18,8 @@
 $Id: utils.py,v 1.21 2005/02/11 09:00:21 shh42 Exp $
 """
 
+import transaction
+
 def setupCoreSessions(app=None):
     '''Sets up the session_data_manager e.a.'''
     from Acquisition import aq_base
@@ -57,7 +59,8 @@
         app._setObject('session_data_manager', sdm)
         commit = 1
 
-    if commit: get_transaction().commit()
+    if commit:
+        transaction.commit()
 
 
 def setupZGlobals(app=None):
@@ -69,7 +72,7 @@
     if not root.has_key('ZGlobals'):
         from BTrees.OOBTree import OOBTree
         root['ZGlobals'] = OOBTree()
-        get_transaction().commit()
+        transaction.commit()
 
 
 def setupSiteErrorLog(app=None):
@@ -84,7 +87,7 @@
             pass
         else:
             app._setObject('error_log', SiteErrorLog())
-            get_transaction().commit()
+            transaction.commit()
 
 
 import os, time
@@ -95,7 +98,7 @@
     start = time.time()
     if not quiet: _print("Importing %s ... " % os.path.basename(filename))
     container._importObjectFromFile(filename, verify=0)
-    get_transaction().commit()
+    transaction.commit()
     if not quiet: _print('done (%.3fs)\n' % (time.time() - start))
 
 

Modified: Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
===================================================================
--- Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2005-03-29 18:11:18 UTC (rev 29720)
+++ Zope/branches/five-integration/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2005-03-29 20:07:16 UTC (rev 29721)
@@ -17,6 +17,7 @@
 
 import sys, re, base64
 import warnings
+import transaction
 
 from zope.testing import doctest
 
@@ -126,7 +127,7 @@
     old_sm = getSecurityManager()
 
     # Commit work done by previous python code.
-    get_transaction().commit()
+    transaction.commit()
 
     # Discard leading white space to make call layout simpler
     request_string = request_string.lstrip()



More information about the Zope-Checkins mailing list