AttributeError:'响应'对象没有属性' _dom'

时间:2014-08-05 07:41:33

标签: python attributes ebay

我正在测试ebaysdk python库,可以让你连接到ebay。现在我正在尝试以下示例:https://github.com/timotheus/ebaysdk-python/

到目前为止,我被这个例子困住了:

from ebaysdk.shopping import Connection as Shopping
shopping = Shopping(domain="svcs.sandbox.ebay.com", config_file="ebay.yaml")
response = shopping.execute('FindPopularItems',
           {'QueryKeywords': 'Python'})
print response.disct()

当我跑的时候。它给了我这个错误:

Traceback (most recent call last):
  File "ebay-test.py", line 13, in <module>
    {'QueryKeywords': 'Python'})
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/connection.py", line 123, in execute
    self.error_check()
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/connection.py", line 193, in error_check
    estr = self.error()
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/connection.py", line 305, in error
    error_array.extend(self._get_resp_body_errors())
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/shopping/__init__.py", line 188, in _get_resp_body_errors
    dom = self.response.dom()
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/response.py", line 229, in dom
    return self._dom
  File "/usr/local/lib/python2.7/dist-packages/ebaysdk-2.1.0-py2.7.egg/ebaysdk/response.py", line 216, in __getattr__
    return getattr(self._obj, name)
AttributeError: 'Response' object has no attribute '_dom'

我在这里遗漏了什么,或者它可能是图书馆中的某种错误?

2 个答案:

答案 0 :(得分:0)

你有配置文件吗?开始使用此SDK时遇到了很多问题。为了让yaml配置文件起作用,我必须指定它所在的目录。所以在你的例子中,它将是:

shopping = Shopping(domain="svcs.sandbox.ebay.com", config_file=os.path.join(os.path.dirname(os.path.realpath(__file__)), 'ebay.yaml'))

您还应该能够在Shopping()声明中指定debug = true,如Shopping(debug=True)中所示。

确保您没有,在配置文件中指定您的APP_ID和其他必要值。

答案 1 :(得分:0)

你的域名错误,应该是'open.api.sandbox.ebay.com'。请参阅ebaysdk github上的此页面。