Saturday, July 7, 2012

Hi djangoers,

I have signals issue I can not figure out. NAy help is greatly appreciated.

So, I have defined my own signal like this in my signals.py:

------- signals.py -------

from django.dispatch import Signal

# Sent when a payment is successfully processed.
payment_successful = Signal(providing_args=["business_id"])

--------


I have a function that needs to send an email on successful payment inside my listeners.py file:

-------- listeners.py --------

@receiver(payment_successful)
def send_email_confirmation(sender, **kwargs):
    #more stuff here
---------


If I call send function from my payment model the receiver function is never called.

---- models.py ------

#this is the line that gets called in models file. I have a print statement in front of it and I know it gets called. 
payment_successful.send(sender=self, business_id=self.id)

-----


Also, I have this line before the above statement and I can see that no receivers are registered inside the payment_successful signal object:

print "receivers: %s", payment_successful.receivers

However, if I open the shell and I pull in a payment and make the same call to the send function like this:

payment_successful.send(sender=payment, business_id=13)

I get the the email sent and if I check payment_successful.receivers I can see the receiver functions in there.

I have no idea why this is. If anyone can help I'll buy you a beer!

Thanks a million!

-m

--
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.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate