我正在尝试在python Google App Engine应用程序中使用suds。这是 追溯:
client = Client(url)
File "/base/data/home/apps/sandbox/test.349741318547153856/suds/client.py",
line 109, in __init__
options.cache = ObjectCache(days=1)
File "/base/data/home/apps/sandbox/test.349741318547153856/suds/cache.py",
line 141, in __init__
location = os.path.join(tmp(), 'suds')
File "/base/python_runtime/python_dist/lib/python2.5/tempfile.py",
line 45, in PlaceHolder
raise NotImplementedError("Only tempfile.TemporaryFile is
available for use")
NotImplementedError: Only tempfile.TemporaryFile is available for use
我尝试在 client.py :
更改第109行options.cache = ObjectCache(days=1)
为:
options.cache = None
它现在有效,但我不确定这是否会影响到某些东西 将来
如果有人能在这里帮助我,我真的很感激。
提前致谢。
答案 0 :(得分:2)
您无法在appengine中写入本地文件。这就是为什么你得到这个错误,它试图将处理后的WSDL缓存写入临时文件。您将不得缓存或提供备用缓存机制。我使用非常昂贵的WSDL文件在appengine上使用suds,所以我破解了缓存以在开发服务器文件系统上写入缓存,然后使用部署的代码上传缓存。
我被骗了 - 有点儿。def precache_wsdl(wsdl,principal):
log = logging.getLogger()
log.setLevel = logging.info
cache_location = os.path.join(os.path.dirname(__file__),"cache")
security = Security()
token = UsernameToken(*principal)
security.tokens.append(token)
client = Client(wsdl,cache=FileCache(cache_location))
client.set_options(wsse=security)
我在appengine代码中定义了这段代码。加载远程命令api,在本地运行, 预先填充缓存。然后我确定在我的真实的appengine代码中正确设置了cach_location。当您在remote_api shell中运行时,您没有运行与服务器代码相同的限制。实际上你甚至不需要在shell下运行它,但我倾向于那么做。
答案 1 :(得分:2)
使用pip中的jurko-suds,并在构造函数中设置cache=
。
from suds.cache import NoCache
[...]
client = Client(url, cache=NoCache())