1
0
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:
Aymeric Augustin
2013-05-19 17:55:12 +02:00
parent bdde7feb26
commit 6633eeb886
4 changed files with 57 additions and 33 deletions

View File

@@ -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 #
############################################