order_success signal called more than once?

7 views
Skip to first unread message

lifewithryan

unread,
Oct 6, 2009, 3:54:33 PM10/6/09
to Satchmo users
I have a developer on my team who is using the order_success signal
to output an xml file that our SAP backend will the pick up.

However, it appears order_success is getting called twice from what we
can tell and we are therefore getting two order files instead of one
per order. Below is a copy of the text he's sent me explaining the
scenario:

I have one method defined in models.py which takes the Order object
passed to it (sender), extracts information from it, formats this
information into xml templates using the Django templating system,
then saves the output xml to a file. Immediately after the method is
defined, the method is registered as a handler for the "order_success"
signal using the syntax "order_success.connect(method)." This occurs
only once in the source. Upon completing an order, two separate xml
files are generated. Both are identical, except for the file's name
which is generated based on a md5 hash of the file salted with the
current unix timestamp. It appears that the signal is being called
twice upon completion of the order. As far as I am aware, this is not
the correct behavior since the balance should only go to zero at one
point in the transaction.

Any ideas??

Chris Moffitt

unread,
Oct 6, 2009, 8:05:18 PM10/6/09
to satchm...@googlegroups.com
Seems strange. What payment module are you using?

-Chris

lifewithryan

unread,
Oct 7, 2009, 7:25:17 AM10/7/09
to satchm...@googlegroups.com
Custom paypal website payments pro that we actually submitted back to bitbucket for you

Sent from my iPod

lifewithryan

unread,
Oct 13, 2009, 6:04:38 PM10/13/09
to Satchmo users
We disabled our custom payment module and still seeing that the
order_success signal is getting called more than once.

We also have the UPS module enabled as well as tiered shipping. Can
you think of anyting else we can look at to try and figure out why
order_success would be getting called twice for one order?

Chris Moffitt

unread,
Oct 13, 2009, 8:00:00 PM10/13/09
to satchm...@googlegroups.com
In looking at the code a little bit (satchmo_store/shop/models.py) around line 917, you'll see that order_success is called for each subtype that has the attribute order_success. Are you using a custom product?

I suspect this is what you're seeing. Is this consistent with what you see in the log file too?

When the signal is called, do the values of the variables you receive change?

-Chris

lifewithryan

unread,
Oct 13, 2009, 9:24:16 PM10/13/09
to satchm...@googlegroups.com
I'll have my teammate check that out.  We are using an a custom product that extends satchmo's product.  So it sounds like you are saying tha the signal gets fired for the custom product and it's parent ( satchmo product)?

Any suggestions ifthat is the case?  We do have a work around in place but wnated to see if there was a root cause that we could fix.

Sent from my iPod

Chris Moffitt

unread,
Oct 13, 2009, 10:35:32 PM10/13/09
to satchm...@googlegroups.com
Take a look at the downloadable product in Satchmo. That uses a custom order_success signal. In that instance, the product subtype is supplied so you could alter behavior based on the type of product.

-Chris

Ryan Headley

unread,
Oct 14, 2009, 10:25:04 AM10/14/09
to satchm...@googlegroups.com
OKay I'm seeing the custom signal on the DownloadableProduct (line 1567 in product/models.py).

My question is, "now what?" 

First a brief history/goal of our intentions:
Upon a successful order, we need to spit out a custom xml file that represents that order.  (An hourly job will then process those orders and run then through an SAP backend).  Our signal code connects a method called sap_export which is responsible for creating this file.  Currently two of these files get generated, as you know, so we've worked around that issue and while it works, we feel there's a "better way."

So, having said that, are you saying that perhaps rather then registering new method with the order_success signal, that we simply put our file creation code into a method call order_success on our custom product model?  Therefore when order_success is fired (from line 917 that you specified earlier) as it loops over subtypes with an order_success method, it will call that code?

Basically we don't need our signal anymore but a method called order_success that will do the same thing our signal method did...

Am I even close?
--
http://www.sudovi.com/
http://www.twitter.com/lifewithryan
http://www.thecommontongue.com
http://www.lifewithryan.com/

Chris Moffitt

unread,
Oct 14, 2009, 10:45:17 AM10/14/09
to satchm...@googlegroups.com
Assuming you are using a custom product - then yes, you could just add order_success to that.

It's a little hard without looking at the exact code to see why it's being called twice but if you only have custom products and have the option to use the custom products order_success method that might be the best option here.

-Chris

Ryan Headley

unread,
Oct 14, 2009, 10:47:35 AM10/14/09
to satchm...@googlegroups.com
Okay...I think I know what you're saying then.

And yes, we have our own Product the extends the default product so we have the ability to add this method.

Thanks!
Reply all
Reply to author
Forward
0 new messages