Thursday, March 29, 2012

Re: Best approach to execute tasks inside django admin views

On Thu, Mar 29, 2012 at 7:40 PM, Marc Aymerich <glicerinu@gmail.com> wrote:
> On Thu, Mar 29, 2012 at 6:28 PM, Marc Aymerich <glicerinu@gmail.com> wrote:
>> Hi guys,
>> I have an application that execute some tasks after an object is
>> modifyed through django admin interface. In order to do that I'm
>> subscribed to django.contrib.admin.models.EntryLog post_save signal
>> and for each signal I execute a celery task.
>>
>> As you migh know django admin views are running under
>> commit_on_success transaction so executing tasks within can lead to
>> some issues, good explained on the celery documentation:
>> http://ask.github.com/celery/userguide/tasks.html#database-transactions
>>
>> So my question is, how do I should deal with this transactions?
>> it is possible to manually commit a commit_on_success transaction
>> before calling the task?
>> if not, what would you do? monkeypatch django admin views to use
>> commit_manually?
>> subclass all your project modelAdmin classes? (I'm using a lot of
>> reusable applications)
>>
>
> Just saw this ticket https://code.djangoproject.com/ticket/14051
>

problem solved by this app:
https://github.com/davehughes/django-transaction-signals

amazing :)

--
Marc

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment