Commit 64a86e6f authored by Tim Peters's avatar Tim Peters

The old commit hook spelling will actually be removed

in 3.8 (it didn't get released in ZODB 3.5; will be
released in ZODB 3.6).
parent 51003b4f
...@@ -39,6 +39,7 @@ __all__ = ['z64', ...@@ -39,6 +39,7 @@ __all__ = ['z64',
'DEPRECATED_ARGUMENT', 'DEPRECATED_ARGUMENT',
'deprecated36', 'deprecated36',
'deprecated37', 'deprecated37',
'deprecated38',
'get_pickle_metadata', 'get_pickle_metadata',
] ]
...@@ -65,6 +66,13 @@ def deprecated37(msg): ...@@ -65,6 +66,13 @@ def deprecated37(msg):
warnings.warn("This will be removed in ZODB 3.7:\n%s" % msg, warnings.warn("This will be removed in ZODB 3.7:\n%s" % msg,
DeprecationWarning, stacklevel=3) DeprecationWarning, stacklevel=3)
# Raise DeprecationWarning, noting that the deprecated thing will go
# away in ZODB 3.8. Point to the caller of our caller (i.e., at the
# code using the deprecated thing).
def deprecated38(msg):
warnings.warn("This will be removed in ZODB 3.8:\n%s" % msg,
DeprecationWarning, stacklevel=3)
z64 = '\0'*8 z64 = '\0'*8
assert sys.hexversion >= 0x02030000 assert sys.hexversion >= 0x02030000
......
...@@ -430,9 +430,9 @@ class Transaction(object): ...@@ -430,9 +430,9 @@ class Transaction(object):
self._before_commit_index += 1 self._before_commit_index += 1
def beforeCommitHook(self, hook, *args, **kws): def beforeCommitHook(self, hook, *args, **kws):
from ZODB.utils import deprecated37 from ZODB.utils import deprecated38
deprecated37("Use addBeforeCommitHook instead of beforeCommitHook.") deprecated38("Use addBeforeCommitHook instead of beforeCommitHook.")
# Default order is zero. # Default order is zero.
self.addBeforeCommitHook(hook, args, kws, order=0) self.addBeforeCommitHook(hook, args, kws, order=0)
......
...@@ -167,11 +167,11 @@ class ITransaction(zope.interface.Interface): ...@@ -167,11 +167,11 @@ class ITransaction(zope.interface.Interface):
raise an exception, or remove `<name, value>` pairs). raise an exception, or remove `<name, value>` pairs).
""" """
# deprecated37 # deprecated38
def beforeCommitHook(__hook, *args, **kws): def beforeCommitHook(__hook, *args, **kws):
"""Register a hook to call before the transaction is committed. """Register a hook to call before the transaction is committed.
THIS IS DEPRECATED IN ZODB 3.5. Use addBeforeCommitHook() instead. THIS IS DEPRECATED IN ZODB 3.6. Use addBeforeCommitHook() instead.
The specified hook function will be called after the transaction's The specified hook function will be called after the transaction's
commit method has been called, but before the commit process has been commit method has been called, but before the commit process has been
......
...@@ -436,7 +436,7 @@ class BeforeCommitHookTests(unittest.TestCase): ...@@ -436,7 +436,7 @@ class BeforeCommitHookTests(unittest.TestCase):
self.assertRaises(ValueError, t.addBeforeCommitHook, self.assertRaises(ValueError, t.addBeforeCommitHook,
hook, order=foo()) hook, order=foo())
# deprecated37; remove this then # deprecated38; remove this then
def test_beforeCommitHook(): def test_beforeCommitHook():
"""Test beforeCommitHook. """Test beforeCommitHook.
...@@ -474,7 +474,7 @@ def test_beforeCommitHook(): ...@@ -474,7 +474,7 @@ def test_beforeCommitHook():
1 1
>>> message, category, filename, lineno = whook.warnings[0] >>> message, category, filename, lineno = whook.warnings[0]
>>> print message >>> print message
This will be removed in ZODB 3.7: This will be removed in ZODB 3.8:
Use addBeforeCommitHook instead of beforeCommitHook. Use addBeforeCommitHook instead of beforeCommitHook.
>>> category.__name__ >>> category.__name__
'DeprecationWarning' 'DeprecationWarning'
......
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