Skip to content

Pagination on a subresource #18

@jtallieu

Description

@jtallieu

I recently ran across a problem where a customer has 100 skus for a product. The API only allows me to get the first 50.

    opts.update({"limit": 50, "page": 1})
    for product in self.con.Products.all(**opts):
         for sku in product.skus():
              print sku

It would be nice if we could pass parameters to the sub resource's all/get method and have it cascade to the connection instance to perform the gets

    stop = False
    skuopts = {"limit": 50, "page": 1}
    while not stop:
       for sku in product.skus(**skuopts):
             print sku

My other option would be to iterate using the SubResource explicitly and passing in the product id and the product's connection, but the connection property is privatized.

    opts.update({"limit": 50, "page": 1})
    for product in self.con.Products.all(**opts):
        stop = False
        skuopts = {"limit": 50, "page": 1}
        while not stop:
           for sku in self.con.ProductSkus.all(product.id, product._connection, **skuopts):
               print sku

This would require exposing the connection object from within the parent resource.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions