#29303: non_atomic_requests decorator alters _non_atomic_requests attribute of
original function
-------------------------------------+-------------------------------------
Reporter: Alasdair Nicol | Owner: Windson
| yang
Type: Bug | Status: assigned
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 Windson yang):
* status: new => assigned
* owner: nobody => Windson yang
Comment:
I'm not sure how to fix this, as we can see, in _non_atomic_requests
method we add 'using' in the original view then return it. That is why
my_view._non_atomic_requests changed. The first solution will copy a new
view from the old one and return the new view. The second will be we make
the document more clear about this behavior.
{{{
def _non_atomic_requests(view, using):
try:
view._non_atomic_requests.add(using)
except AttributeError:
view._non_atomic_requests = {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)
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29303#comment:4>
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.7ab1474ba65ab87be0e56ada2b8093f0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.