#29557: add on_commit decorator
-------------------------------------+-------------------------------------
     Reporter:  obayemi              |                    Owner:  nobody
         Type:  New feature          |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:  transaction          |             Triage Stage:
  on_commit decorator                |  Unreviewed
    Has patch:  1                    |      Needs documentation:  1
  Needs tests:  1                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => wontfix


Comment:

 Hi @obayemi.

 Having considered this more I'm going to go with `wontfix`.

 You're obviously welcome to use a decorator such as this in your own
 project but, using `on_commit()` directly is going to result in
 significantly clearer code.

 In your example, do this:


 {{{
 with transaction.atomic():
     group = Group.objects.create()
     group.users.add(Users.objects.all()
     transaction.on_commit(notify_users)
 }}}

 By shipping a call_on_commit decorator we'd be guiding people towards
 writing less clear code. I think we're not doing anyone any favours there.

 Thanks for the input!

-- 
Ticket URL: <https://code.djangoproject.com/ticket/29557#comment:9>
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/065.e21380270e293506f962c07b546c8e97%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to