1
0
mirror of https://github.com/django/django.git synced 2025-10-25 14:46:09 +00:00

Made transaction.managed a no-op and deprecated it.

enter_transaction_management() was nearly always followed by managed().

In three places it wasn't, but they will all be refactored eventually.
The "forced" keyword argument avoids introducing behavior changes until
then.

This is mostly backwards-compatible, except, of course, for managed
itself. There's a minor difference in _enter_transaction_management:
the top self.transaction_state now contains the new 'managed' state
rather than the previous one. Django doesn't access
self.transaction_state in _enter_transaction_management.
This commit is contained in:
Aymeric Augustin
2013-03-02 20:25:25 +01:00
parent 9cec689e6a
commit 7aacde84f2
14 changed files with 22 additions and 64 deletions

View File

@@ -67,7 +67,6 @@ real_commit = transaction.commit
real_rollback = transaction.rollback
real_enter_transaction_management = transaction.enter_transaction_management
real_leave_transaction_management = transaction.leave_transaction_management
real_managed = transaction.managed
real_abort = transaction.abort
def nop(*args, **kwargs):
@@ -78,7 +77,6 @@ def disable_transaction_methods():
transaction.rollback = nop
transaction.enter_transaction_management = nop
transaction.leave_transaction_management = nop
transaction.managed = nop
transaction.abort = nop
def restore_transaction_methods():
@@ -86,7 +84,6 @@ def restore_transaction_methods():
transaction.rollback = real_rollback
transaction.enter_transaction_management = real_enter_transaction_management
transaction.leave_transaction_management = real_leave_transaction_management
transaction.managed = real_managed
transaction.abort = real_abort
@@ -833,7 +830,6 @@ class TestCase(TransactionTestCase):
for db_name in self._databases_names():
transaction.enter_transaction_management(using=db_name)
transaction.managed(True, using=db_name)
disable_transaction_methods()
from django.contrib.sites.models import Site