Commit e3576589 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 49b080e7
...@@ -2,6 +2,23 @@ What's new in ZODB3 3.4? ...@@ -2,6 +2,23 @@ What's new in ZODB3 3.4?
======================== ========================
Release date: DD-MMM-2004 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 DB
-- --
......
...@@ -31,8 +31,8 @@ del mapping, list, sys ...@@ -31,8 +31,8 @@ del mapping, list, sys
from DB import DB from DB import DB
from transaction import get as get_transaction # TODO: get_transaction() scheduled to go away in ZODB 3.6.
# TODO Issue deprecation warning if this variant is used? from transaction import get_transaction
__builtin__.get_transaction = get_transaction __builtin__.get_transaction = get_transaction
del __builtin__ del __builtin__
...@@ -158,7 +158,7 @@ class DBMethods(CacheTestBase): ...@@ -158,7 +158,7 @@ class DBMethods(CacheTestBase):
d = r[1] d = r[1]
for i in range(len(d)): for i in range(len(d)):
d[i] = CantGetRidOfMe(i) d[i] = CantGetRidOfMe(i)
get_transaction().commit() transaction.commit()
self.testcase.db.cacheMinimize() self.testcase.db.cacheMinimize()
......
...@@ -153,7 +153,7 @@ class FileStorageTests( ...@@ -153,7 +153,7 @@ class FileStorageTests(
# Replace the OOBTree with a dictionary and commit it. # Replace the OOBTree with a dictionary and commit it.
self._storage._index._data = data_dict self._storage._index._data = data_dict
get_transaction().commit() transaction.commit()
# Save the index. # Save the index.
self._storage.close() self._storage.close()
...@@ -198,7 +198,7 @@ class FileStorageTests( ...@@ -198,7 +198,7 @@ class FileStorageTests(
db = DB(self._storage) db = DB(self._storage)
conn = db.open() conn = db.open()
conn.root()['xyz'] = 1 conn.root()['xyz'] = 1
get_transaction().commit() transaction.commit()
true_max_oid = self._storage._oid true_max_oid = self._storage._oid
# Save away the index, and poke in a bad 'oid' value by hand. # Save away the index, and poke in a bad 'oid' value by hand.
...@@ -288,7 +288,7 @@ class FileStorageTests( ...@@ -288,7 +288,7 @@ class FileStorageTests(
db = DB(self._storage) db = DB(self._storage)
conn = db.open() conn = db.open()
conn.root()['xyz'] = 1 conn.root()['xyz'] = 1
get_transaction().commit() transaction.commit()
# Ensure it's all on disk. # Ensure it's all on disk.
db.close() db.close()
...@@ -330,7 +330,7 @@ class FileStorageTests( ...@@ -330,7 +330,7 @@ class FileStorageTests(
conn = db.open() conn = db.open()
conn.root()['abc'] = MinPO('abc') conn.root()['abc'] = MinPO('abc')
conn.root()['xyz'] = MinPO('xyz') conn.root()['xyz'] = MinPO('xyz')
get_transaction().commit() transaction.commit()
# Ensure it's all on disk. # Ensure it's all on disk.
db.close() db.close()
......
...@@ -21,10 +21,6 @@ import persistent ...@@ -21,10 +21,6 @@ import persistent
import transaction import transaction
from ZODB.MappingStorage import MappingStorage from ZODB.MappingStorage import MappingStorage
from ZODB.DB import DB as _DB 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'): def DB(name='Test'):
return _DB(MappingStorage(name)) return _DB(MappingStorage(name))
......
...@@ -30,6 +30,7 @@ import shutil ...@@ -30,6 +30,7 @@ import shutil
import ZODB import ZODB
from ZODB import FileStorage from ZODB import FileStorage
import transaction
PYTHON = sys.executable + ' ' PYTHON = sys.executable + ' '
...@@ -48,7 +49,7 @@ class OurDB: ...@@ -48,7 +49,7 @@ class OurDB:
self.getdb() self.getdb()
conn = self.db.open() conn = self.db.open()
conn.root()['tree'] = OOBTree() conn.root()['tree'] = OOBTree()
get_transaction().commit() transaction.commit()
self.close() self.close()
def getdb(self): def getdb(self):
...@@ -98,7 +99,7 @@ def mutatedb(db): ...@@ -98,7 +99,7 @@ def mutatedb(db):
keys = tree.keys() keys = tree.keys()
if keys: if keys:
del tree[keys[0]] del tree[keys[0]]
get_transaction().commit() transaction.commit()
db.close() db.close()
def main(): def main():
......
...@@ -33,5 +33,7 @@ def commit(sub=False): ...@@ -33,5 +33,7 @@ def commit(sub=False):
def abort(sub=False): def abort(sub=False):
manager.get().abort(sub) manager.get().abort(sub)
# TODO: Issue deprecation warning if this variant is used? def get_transaction():
get_transaction = get 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