views:

197

answers:

1

Ok I'm working on getting better with python, so I'm not sure this is the right way to go about what I'm doing to begin with, but here's my current problem...

I need to get some information via a SOAP method, and only use part of the information now but store the entire result for future uses (we need to use the service as little as possible). Looking up the best way to access the service I figured suds was the way to go, and it was simple and worked like a charm to get the data. But now I want to save the result somehow, preferably serialized / in a database so I can pull it out later and use it the same.

What's the best way to do this, it looks like pickle/json isn't an option? Thanks!

Update Reading the top answer at http://stackoverflow.com/questions/2167894/how-can-i-pickle-suds-results gives me a better idea of why this isn't an option, I guess I'm stuck recreating a basic object w/ the information I need?

A: 

Yep, I confirm the explanation I gave in the answer you refer to -- dynamically generated classes are not easily picklable (nor otherwise easily serializable), you need to extract all the state information, pickle that state, and reconstruct the tricky sudsobject on retrieval if you really insist on using it;-).

Alex Martelli
I'm using the 'retxml=True' option to just get the raw result back and then turning that into a dict (which should be serializable) now - looks like it will work... thanks!
pssdbt
@pssdbt, excellent -- or you could serialize the XML itself, but I believe that unpickling a pickled dict will be faster than parsing the XML, so I think you've made the right choice.
Alex Martelli