开发者

Suds ignoring cache setting?

I'm using suds 0.3.8, Python 2.4.3, and Django 1.1.1. The code I inherited has a long duration for the cached files, but it's expiring on the default cadence of once every 24 hours. The external servers hosting the schemas are spotty, so the site is going down nightly and I'm at the end of my rope.

Any idea what is jacked up in this code?

imp = Import('http://domain2.com/url')
imp.filter.add('http://domain3.com/url')
imp.filter.add('http://domain4.com/url')
imp.filter.add('http://domain5.com/url')
d = ImportDoctor(imp)

url = "http://domain.com/wsdl"
client = Client(url, doctor=d, timeout=30)
clientcache = client.options.cache
clientcache.setduration(da开发者_如何学Goys=360)


Answering my own question:

This ended up not being a version issue, but user error. Unfortunately the suds documentation isn't as clear as it could be. Reading it, one would think the code above would work, but (on suds v0.39+) it should be written as:

imp = Import('http://domain2.com/url')
imp.filter.add('http://domain3.com/url')
imp.filter.add('http://domain4.com/url')
imp.filter.add('http://domain5.com/url')
d = ImportDoctor(imp)

oc = ObjectCache()
oc.setduration(days=360)

url = "http://domain.com/wsdl"
client = Client(url, doctor=d, cache=oc, timeout=30)

Looking at it now, it makes complete sense that the cache has to be configured before the Client is initialized.

Hopefully this will help anyone else trying to set a suds cache, and it seems to be ignoring your settings.


The problem may be a lack of proper support in the default cache type in the Suds 0.3.8, or possibly even a bug in this version. If you're able to upgrade to Suds 0.3.9 or later (latest is 0.4), that would allow this behavior to work as expected.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜