#29303: non_atomic_requests decorator alters _non_atomic_requests attribute of
original function
-------------------------------------+-------------------------------------
     Reporter:  Alasdair Nicol       |                    Owner:  Windson
                                     |  yang
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  needsinfo
     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:  assigned => closed
 * resolution:   => needsinfo


Comment:

 I don't think this is a bug, in your example wrapped_view is my_view. You
 can use id() to find out.


 {{{
 class TestViews(TestCase):

     def test(self):
         assert my_view._non_atomic_requests == {'default'}  # passes
         wrapped_view =
 transaction.non_atomic_requests(using='other')(my_view)
         print(id(wrapped_view)) # 4510701904
         print(id(my_view)) # 4510701904
         assert wrapped_view._non_atomic_requests == {'default', 'other'}
 # passes
         assert my_view._non_atomic_requests == {'default'}  # fails
 }}}

 If you want to define a new view, you should use


 {{{
 wrapped_view =
 transaction.non_atomic_requests(using='other')(wrapped_view)
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29303#comment:5>
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.3d5a79fc0906853c44a431227610aeef%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to