Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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(days=360)
like image 663
Mark Phillip Avatar asked Dec 21 '22 13:12

Mark Phillip


1 Answers

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.

like image 143
Mark Phillip Avatar answered Dec 28 '22 06:12

Mark Phillip