#29557: add on_commit decorator
-------------------------------------+-------------------------------------
     Reporter:  obayemi              |                    Owner:  nobody
         Type:  New feature          |                   Status:  new
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     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):

 * cc: Carlton Gibson (added)


Comment:

 I think you need to explain the usage more fully here.

 I'm expecting this sort of thing:

 {{{
 def send_mail()
     ...

 with transaction.atomic():
     Thing.objects.create(num=num)
     transaction.on_commit(send_mail)
 }}}

 You need to explain how the decorator would work.

 From the docs:

 > If you call on_commit() while there isn’t an active transaction, the
 callback will be executed immediately.

 So you can't just decorate `send_mail()` at the point of declaration here.
 So what would your code look like?

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

Reply via email to