我正在使用django和Google App Engine。我无法确定错误的来源,因为如果我在本地网站上使用它的话就会运行。我在GAE上部署它后工作正常,但使用googleadwords api时出现错误:
NotImplementedError: Only tempfile.TemporaryFile is available for use
at PlaceHolder (/base/alloc/tmpfs/dynamic_runtimes/python27/a7637d5531ec9deb_unzipped/python27_dist/lib/python2.7/tempfile.py:45)
at __init__ (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/suds/cache.py:115)
at __init__ (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/suds/client.py:112)
at GetService (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/googleads/adwords.py:459)
at post (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/ksvt/views.py:47)
at dispatch (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/views/generic/base.py:88)
at view (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/views/generic/base.py:68)
at _get_response (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/core/handlers/base.py:185)
at _get_response (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/core/handlers/base.py:187)
at inner (/base/data/home/apps/f~xxxx/20180320t181216.408435502723573470/lib/django/core/handlers/exception.py:41)
有人可以解释这个错误是什么意思吗?谢谢!
编辑: 我认为代码行会产生错误。
adwords_client = adwords.AdWordsClient.LoadFromStorage(os.path.dirname(os.path.abspath(__file__)) + "//googleads.yaml")
答案 0 :(得分:5)
adwords库正在使用suds
将SOAP消息发送到adwords API。 suds包尝试在文件系统中缓存数据,这在App Engine标准环境中是禁止的。
Adwords包README介绍了如何通过将虚拟缓存实现传递给adwords客户端来禁用缓存:
adwords_client = adwords.AdWordsClient(
developer_token, oauth2_client, user_agent,
client_customer_id=client_customer_id, cache=suds.cache.NoCache())
(您需要导入suds.cache
)