-2

これが私が使おうとしているクラスです

class Products(Resource):
    """The collection of products in a store"""

    def get(self):
        """Returns list of products"""
        products_list = self.client.request_json('GET', '/products?limit=%s&page=%s' % (self.paginate_by, self.current_page))
        return [Product(product) for product in products_list]

これが私のスクリプトです:

import bigcommerce.api

bigcommerce.api.Connection.host = 'https://store-qvek.mybigcommerce.com'
bigcommerce.api.Connection.user = 'admin'
bigcommerce.api.Connection.api_key = '272956b18e3a7c269b413385908cc7371f5c41'


products_list = bigcommerce.api.Products.get()
for product in products_list:
    print product.name

Products.get()....に何かが足りませんが、何ですか?

Traceback (most recent call last):
  File "C:\wget\bin\test_bigcommerce.py", line 8, in <module>
    products_list = bigcommerce.api.Products.get()
TypeError: unbound method get() must be called with Products instance as first argument (got nothing instead) 

PS公開するためにホストとAPIキーを変更したため、コードが機能しません。

4

1 に答える 1

0

クラスProductsはありますが、そのインスタンスを作成することはありません。

代わりにインスタンスを作成します。

bigcommerce.api.Products().get()
于 2013-03-09T23:18:22.430 に答える