#29303: non_atomic_requests decorator alters _non_atomic_requests attribute of
original function
-------------------------------------+-------------------------------------
Reporter: Alasdair Nicol | Owner: Windson
| yang
Type: Bug | Status: new
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Alasdair Nicol):
* status: closed => new
* resolution: needsinfo =>
Comment:
Replying to [comment:5 Windson yang]:
> I don't think this is a bug, in your example wrapped_view is my_view.
You can use id() to find out.
That explains why the test case is failing, but it's not clear that that
should be the behaviour. Why should `wrapped_view` be `my_view`?
If you wrap a view with `transaction.atomic()`, you get a new view:
{{{
def my_view(request):
return HttpResponse('Hello, world')
wrapped_view = transaction.atomic(my_view)
assert wrapped_view is not my_view
}}}
But when you wrap a view with `transaction.non_atomic_requests`, it
modifies the original view.
{{{
def my_view(request):
return HttpResponse('Hello, world')
wrapped_view = transaction.non_atomic_requests(my_view)
assert wrapped_view is my_view
}}}
This behaviour is inconsistent.
As I said in the original ticket, I'm not sure that this is a problem in
practice. I assume that most of the time, `non_atomic_requests` is used as
a decorator, so you don't need the original unwrapped view.
{{{
@transaction.non_atomic_requests(using='default')
@transaction.non_atomic_requests(using='other')
def my_view(request)
return HttpResponse('')
}}}
I'd understand if we closed this ticket as WONTFIX or simply added a note
to the documentation, but I think that closing as NEEDSINFO is incorrect.
--
Ticket URL: <https://code.djangoproject.com/ticket/29303#comment:6>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/071.39eacbc26d486b6bac6198071459f026%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.