3 | | Exactly. That's why we monkey patched {{{ BaseHandler.make_view_atomic }}}. |
| 3 | Exactly. That's why we monkey patched [https://github.com/django/django/blob/16411b8400ad08f90c236bb2e18f65c655f903f8/django/core/handlers/base.py#L78|{{{ BaseHandler.make_view_atomic]. |
| 4 | |
| 5 | |
| 6 | Basically like this: |
| 7 | {{{ |
| 8 | def make_view_atomic(self, view): |
| 9 | non_atomic_requests = getattr(view, '_non_atomic_requests', set()) |
| 10 | for db in connections.all(): |
| 11 | if (db.settings_dict['ATOMIC_REQUESTS'] |
| 12 | and db.alias not in non_atomic_requests): |
| 13 | view = transaction.atomic(using=db.alias)(yet_another_wrapper(view)) |
| 14 | return view |
| 15 | |
| 16 | def yet_another_wrapper(view): |
| 17 | def wrapped_view(request, *args, **kwargs): |
| 18 | # do what legacy systems usually do |
| 19 | # weird stuff |
| 20 | # custom things |
| 21 | return view(request, *args, **kwargs) |
| 22 | return wrapped_view |
| 23 | }}} |