Re: Best approach to execute tasks inside django admin views

2012-03-29 Thread Marc Aymerich
On Thu, Mar 29, 2012 at 7:40 PM, Marc Aymerich  wrote:
> On Thu, Mar 29, 2012 at 6:28 PM, Marc Aymerich  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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Best approach to execute tasks inside django admin views

2012-03-29 Thread Marc Aymerich
On Thu, Mar 29, 2012 at 6:28 PM, Marc Aymerich  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

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Best approach to execute tasks inside django admin views

2012-03-29 Thread Marc Aymerich
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)

thank you guys!
-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.