diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-05-19 17:55:12 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2013-05-19 19:53:16 +0200 |
| commit | 6633eeb88634aa8c03c8737d2d23c96b96a37e0d (patch) | |
| tree | 96d3e96cf471286afe9273101c50fe91be0aa500 /django/db/transaction.py | |
| parent | bdde7feb26f89e580c2b21154196fe3f8c774677 (diff) | |
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.
Diffstat (limited to 'django/db/transaction.py')
| -rw-r--r-- | django/db/transaction.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/django/db/transaction.py b/django/db/transaction.py index 48e7f900dd..f770f2efa7 100644 --- a/django/db/transaction.py +++ b/django/db/transaction.py @@ -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 # ############################################ |
