Commit d058ebfe authored by Tim Peters's avatar Tim Peters

Officially deprecate the monkey-patching of get_transaction into __builtin__.

Various Zopes probably need changes too (to avoid the new deprecation
warnings).
parent 34b93664
......@@ -2,6 +2,23 @@ What's new in ZODB3 3.4?
========================
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
--
......
......@@ -31,8 +31,8 @@ del mapping, list, sys
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__
......@@ -158,7 +158,7 @@ class DBMethods(CacheTestBase):
d = r[1]
for i in range(len(d)):
d[i] = CantGetRidOfMe(i)
get_transaction().commit()
transaction.commit()
self.testcase.db.cacheMinimize()
......
......@@ -153,7 +153,7 @@ class FileStorageTests(
# 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 @@ class FileStorageTests(
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 @@ class FileStorageTests(
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 @@ class FileStorageTests(
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()
......
......@@ -21,10 +21,6 @@ import persistent
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))
......
......@@ -30,6 +30,7 @@ import shutil
import ZODB
from ZODB import FileStorage
import transaction
PYTHON = sys.executable + ' '
......@@ -48,7 +49,7 @@ class OurDB:
self.getdb()
conn = self.db.open()
conn.root()['tree'] = OOBTree()
get_transaction().commit()
transaction.commit()
self.close()
def getdb(self):
......@@ -98,7 +99,7 @@ def mutatedb(db):
keys = tree.keys()
if keys:
del tree[keys[0]]
get_transaction().commit()
transaction.commit()
db.close()
def main():
......
......@@ -33,5 +33,7 @@ def commit(sub=False):
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()
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