I want to check for new orders in the background?

26 views
Skip to first unread message

frocco

unread,
Mar 5, 2013, 8:38:14 AM3/5/13
to django...@googlegroups.com
Hello,

I want to query the orders database every 5 minutes and alert admins that new orders have arrived.
Would I use signals for this?

Anyone have an example?

Thank you

frocco

unread,
Mar 5, 2013, 8:49:46 AM3/5/13
to django...@googlegroups.com
Would I send a signal after an order is saved?

frocco

unread,
Mar 5, 2013, 9:09:35 AM3/5/13
to django...@googlegroups.com
This is not working, the to: never gets called.

from:
user_order = Signal(providing_args=["request", "order"])
user_order.send(sender=None, request=request, order=order)


to:
def user_order_handler(sender, **kwargs):
        order = kwargs('order')

user_order.connect(user_order_handler)

Dave Murphy

unread,
Mar 5, 2013, 9:10:51 AM3/5/13
to django...@googlegroups.com
On Tuesday, March 5, 2013 1:38:14 PM UTC, frocco wrote:
I want to query the orders database every 5 minutes and alert admins that new orders have arrived.
Would I use signals for this?

Using a receiver attached to the post_save signal of your Order model would certainly be more efficient than polling the database. You could also generate the e-mail inside the save() method of your model. However you need to be careful as both may block your application.
 
Anyone have an example?

Jaimin Patel

unread,
Mar 5, 2013, 9:18:04 AM3/5/13
to django...@googlegroups.com
Take a look at django-notifications app - https://github.com/pinax/django-notification

I think it should be able to help you.



On Tuesday, March 5, 2013 8:38:14 AM UTC-5, frocco wrote:

frocco

unread,
Mar 5, 2013, 9:28:31 AM3/5/13
to django...@googlegroups.com
I tried your link https://github.com/pinax/django-notification
but it is not working.

is there anything wrong with my code to prevent the signal from working?

frocco

unread,
Mar 5, 2013, 2:04:32 PM3/5/13
to django...@googlegroups.com
I got this working using signals
Reply all
Reply to author
Forward
0 new messages