Python Shopify Image API

时间:2012-09-27 15:01:39

标签: shopify

我正在尝试使用Shopify的python API来检索产品图片列表,但我收到了一个错误。我认为这是因为网址格式错误。对此有什么修正吗?

images = shopify.Image.find(product.id)

错误堆栈跟踪:

Traceback:
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/core/handlers/base.py" in get_response
  105.                         response = middleware_method(request, callback, callback_args, callback_kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/mezzanine/pages/middleware.py" in process_view
  45.             return view_func(request, *view_args, **view_kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/views/generic/base.py" in view
  48.             return self.dispatch(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/contrib/auth/decorators.py" in _wrapped_view
  20.                 return view_func(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_app/decorators.py" in wrapper
  10.         return func(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_galleries/views.py" in dispatch
  93.         return super(ListProductsView, self).dispatch(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/views/generic/base.py" in dispatch
  69.         return handler(request, *args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/src/django/django/views/generic/list.py" in get
  114.         self.object_list = self.get_queryset()
File "/home/rodxavierbondoc/workspace/sg/djangoproject/shopify_galleries/views.py" in get_queryset
  100.             image = shopify.Image.find(product.id)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/activeresource.py" in find
  349.             return cls._find_single(id_, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/activeresource.py" in _find_single
  452.         return cls._build_object(cls.connection.get(path, cls.headers),
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/connection.py" in get
  328.         return self.format.decode(self._open('GET', path, headers=headers).body)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/shopify/base.py" in _open
  18.             self.response = super(ShopifyConnection, self)._open(*args, **kwargs)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/connection.py" in _open
  287.                 http_response = self._handle_error(err)
File "/home/rodxavierbondoc/.virtualenvs/shopify/local/lib/python2.7/site-packages/pyactiveresource/connection.py" in _handle_error
  407.             raise ResourceNotFound(err)

Exception Type: ResourceNotFound at /galleries/1/products/
Exception Value: Not Found: https://sawayn-and-sons9677.myshopify.com/admin/products//images/103786527.xml

1 个答案:

答案 0 :(得分:4)

Product Images API中的product_idprefix option,使用关键字参数指定。

images = shopify.Image.find(product_id=product.id)