mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Changed API to disable ATOMIC_REQUESTS per view.
A decorator is easier to apply to CBVs. Backwards compatibility isn't an issue here, except for people running on a recent clone of master. Fixed a few minor problems in the transactions docs while I was there.
This commit is contained in:
@@ -333,6 +333,23 @@ def atomic(using=None, savepoint=True):
|
||||
return Atomic(using, savepoint)
|
||||
|
||||
|
||||
def _non_atomic_requests(view, using):
|
||||
try:
|
||||
view._non_atomic_requests.add(using)
|
||||
except AttributeError:
|
||||
view._non_atomic_requests = set([using])
|
||||
return view
|
||||
|
||||
|
||||
def non_atomic_requests(using=None):
|
||||
if callable(using):
|
||||
return _non_atomic_requests(using, DEFAULT_DB_ALIAS)
|
||||
else:
|
||||
if using is None:
|
||||
using = DEFAULT_DB_ALIAS
|
||||
return lambda view: _non_atomic_requests(view, using)
|
||||
|
||||
|
||||
############################################
|
||||
# Deprecated decorators / context managers #
|
||||
############################################
|
||||
|
||||
Reference in New Issue
Block a user