1
0
mirror of https://github.com/django/django.git synced 2025-10-29 08:36:09 +00:00

Deprecated TransactionMiddleware and TRANSACTIONS_MANAGED.

Replaced them with per-database options, for proper multi-db support.

Also toned down the recommendation to tie transactions to HTTP requests.
Thanks Jeremy for sharing his experience.
This commit is contained in:
Aymeric Augustin
2013-03-06 11:12:24 +01:00
parent f7245b83bb
commit ac37ed21b3
12 changed files with 217 additions and 51 deletions

View File

@@ -1,4 +1,7 @@
from django.db import transaction
import warnings
from django.core.exceptions import MiddlewareNotUsed
from django.db import connection, transaction
class TransactionMiddleware(object):
"""
@@ -7,6 +10,14 @@ class TransactionMiddleware(object):
commit, the commit is done when a successful response is created. If an
exception happens, the database is rolled back.
"""
def __init__(self):
warnings.warn(
"TransactionMiddleware is deprecated in favor of ATOMIC_REQUESTS.",
PendingDeprecationWarning, stacklevel=2)
if connection.settings_dict['ATOMIC_REQUESTS']:
raise MiddlewareNotUsed
def process_request(self, request):
"""Enters transaction management"""
transaction.enter_transaction_management()