在python中序列化suds对象 [英] Serializing a suds object in python

查看:310
本文介绍了在python中序列化suds对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我正在努力使python变得更好,所以我不确定这是开始工作的正确方法,但这是我当前的问题...

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

我需要通过SOAP方法获取一些信息,并且现在仅使用部分信息,但将整个结果存储起来以备将来使用(我们需要尽可能少地使用该服务).寻找通往我认为最合适的服务的最佳方法就是要走的路,它很简单,而且就像获取数据的一种魅力.但是现在我想以某种方式保存结果,最好将其序列化/保存在数据库中,这样我以后就可以将其拉出并以相同的方式使用.

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.

执行此操作的最佳方法是什么,似乎无法选择pickle/json?谢谢!

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

更新 阅读我如何腌制肥皂水结果的最佳答案?给我一个更好的答案想到为什么这不是一个选择,我想我一直在用需要的信息重新创建一个基本对象?

Update Reading the top answer at 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?

推荐答案

是的,我确认我在您所指的答案中给出的解释-动态生成的类不容易提取(也不容易序列化),您需要提取所有状态信息,腌制那个状态,如果确实坚持使用它,则在检索时重建棘手的sudsobject;-).

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

这篇关于在python中序列化suds对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆