[Zodb-checkins] SVN: ZODB/trunk/ Officially deprecate the monkey-patching of get_transaction into __builtin__.

Tim Peters tim.one at comcast.net
Tue Mar 22 15:51:18 EST 2005


Log message for revision 29640:
  Officially deprecate the monkey-patching of get_transaction into __builtin__.
  
  Various Zopes probably need changes too (to avoid the new deprecation
  warnings).
  

Changed:
  U   ZODB/trunk/NEWS.txt
  U   ZODB/trunk/src/ZODB/__init__.py
  U   ZODB/trunk/src/ZODB/tests/testCache.py
  U   ZODB/trunk/src/ZODB/tests/testFileStorage.py
  U   ZODB/trunk/src/ZODB/tests/util.py
  U   ZODB/trunk/src/scripts/manual_tests/testrepozo.py
  U   ZODB/trunk/src/transaction/__init__.py

-=-
Modified: ZODB/trunk/NEWS.txt
===================================================================
--- ZODB/trunk/NEWS.txt	2005-03-22 20:48:23 UTC (rev 29639)
+++ ZODB/trunk/NEWS.txt	2005-03-22 20:51:18 UTC (rev 29640)
@@ -2,6 +2,23 @@
 ========================
 Release date: DD-MMM-2004
 
+transaction
+-----------
+
+- ``get_transaction()`` is officially deprecated now, and will be removed
+  in ZODB 3.6.  Use the ``transaction`` package instead.   For example,
+  instead of::
+
+      import ZODB
+      ...
+      get_transaction().commit()
+
+  do::
+
+      import transaction
+      ...
+      transaction.commit()
+
 DB
 --
 

Modified: ZODB/trunk/src/ZODB/__init__.py
===================================================================
--- ZODB/trunk/src/ZODB/__init__.py	2005-03-22 20:48:23 UTC (rev 29639)
+++ ZODB/trunk/src/ZODB/__init__.py	2005-03-22 20:51:18 UTC (rev 29640)
@@ -31,8 +31,8 @@
 
 from DB import DB
 
-from transaction import get as get_transaction
-# TODO Issue deprecation warning if this variant is used?
+# TODO:  get_transaction() scheduled to go away in ZODB 3.6.
+from transaction import get_transaction
 __builtin__.get_transaction = get_transaction
 
 del __builtin__

Modified: ZODB/trunk/src/ZODB/tests/testCache.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testCache.py	2005-03-22 20:48:23 UTC (rev 29639)
+++ ZODB/trunk/src/ZODB/tests/testCache.py	2005-03-22 20:51:18 UTC (rev 29640)
@@ -158,7 +158,7 @@
                 d = r[1]
                 for i in range(len(d)):
                     d[i] = CantGetRidOfMe(i)
-                get_transaction().commit()
+                transaction.commit()
 
                 self.testcase.db.cacheMinimize()
 

Modified: ZODB/trunk/src/ZODB/tests/testFileStorage.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/testFileStorage.py	2005-03-22 20:48:23 UTC (rev 29639)
+++ ZODB/trunk/src/ZODB/tests/testFileStorage.py	2005-03-22 20:51:18 UTC (rev 29640)
@@ -153,7 +153,7 @@
 
         # Replace the OOBTree with a dictionary and commit it.
         self._storage._index._data = data_dict
-        get_transaction().commit()
+        transaction.commit()
 
         # Save the index.
         self._storage.close()
@@ -198,7 +198,7 @@
         db = DB(self._storage)
         conn = db.open()
         conn.root()['xyz'] = 1
-        get_transaction().commit()
+        transaction.commit()
         true_max_oid = self._storage._oid
 
         # Save away the index, and poke in a bad 'oid' value by hand.
@@ -288,7 +288,7 @@
         db = DB(self._storage)
         conn = db.open()
         conn.root()['xyz'] = 1
-        get_transaction().commit()
+        transaction.commit()
 
         # Ensure it's all on disk.
         db.close()
@@ -330,7 +330,7 @@
         conn = db.open()
         conn.root()['abc'] = MinPO('abc')
         conn.root()['xyz'] = MinPO('xyz')
-        get_transaction().commit()
+        transaction.commit()
 
         # Ensure it's all on disk.
         db.close()

Modified: ZODB/trunk/src/ZODB/tests/util.py
===================================================================
--- ZODB/trunk/src/ZODB/tests/util.py	2005-03-22 20:48:23 UTC (rev 29639)
+++ ZODB/trunk/src/ZODB/tests/util.py	2005-03-22 20:51:18 UTC (rev 29640)
@@ -21,10 +21,6 @@
 import transaction
 from ZODB.MappingStorage import MappingStorage
 from ZODB.DB import DB as _DB
-try:
-    from transaction import get_transaction
-except ImportError:
-    pass # else assume ZODB will install it as a builtin
 
 def DB(name='Test'):
     return _DB(MappingStorage(name))

Modified: ZODB/trunk/src/scripts/manual_tests/testrepozo.py
===================================================================
--- ZODB/trunk/src/scripts/manual_tests/testrepozo.py	2005-03-22 20:48:23 UTC (rev 29639)
+++ ZODB/trunk/src/scripts/manual_tests/testrepozo.py	2005-03-22 20:51:18 UTC (rev 29640)
@@ -30,6 +30,7 @@
 
 import ZODB
 from ZODB import FileStorage
+import transaction
 
 PYTHON = sys.executable + ' '
 
@@ -48,7 +49,7 @@
         self.getdb()
         conn = self.db.open()
         conn.root()['tree'] = OOBTree()
-        get_transaction().commit()
+        transaction.commit()
         self.close()
 
     def getdb(self):
@@ -98,7 +99,7 @@
             keys = tree.keys()
             if keys:
                 del tree[keys[0]]
-    get_transaction().commit()
+    transaction.commit()
     db.close()
 
 def main():

Modified: ZODB/trunk/src/transaction/__init__.py
===================================================================
--- ZODB/trunk/src/transaction/__init__.py	2005-03-22 20:48:23 UTC (rev 29639)
+++ ZODB/trunk/src/transaction/__init__.py	2005-03-22 20:51:18 UTC (rev 29640)
@@ -33,5 +33,7 @@
 def abort(sub=False):
     manager.get().abort(sub)
 
-# TODO: Issue deprecation warning if this variant is used?
-get_transaction = get
+def get_transaction():
+    from ZODB.utils import deprecated36
+    deprecated36("   use transaction.get() instead of get_transaction()")
+    return get()



More information about the Zodb-checkins mailing list