[PonyORM-list] does pony provide pagination functionality

Alexander Kozlovsky alexander.kozlovsky at gmail.com
Sat Dec 14 18:59:06 UTC 2013


On Sat, Dec 14, 2013 at 10:09 PM, Guy Jacks <guy.jacks at gmail.com> wrote:
> I have Pony working well for a small app but I can't find any
documentation on pagination.  Does Pony offer any pagination features?

Yes, in the development version of Pony (which you can take from GitHub)
the query object has "page(pagenum, pagesize)" method. It may be used as in
the following examples:

  select(p for p in Product).page(3)  # 10 items per page by default
  select(p for p in Product).page(3, pagesize=20)

Also it is possible to use slice syntax. The above queries can be
equivalently written as:

  select(p for p in Product)[20:30]
  select(p for p in Product)[40:60]

When using slice syntax, the general formula is [(pagenum - 1) * pagesize :
pagenum * pagesize]

page() method will be included in the upcoming release PonyORM 0.5. All
previous releases support slice syntax.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20131214/2042130b/attachment.html>


More information about the ponyorm-list mailing list