Hi guys,
I rewrote the pagination class originated from Ryan's idea [1]. In
case you missed it, it "supports efficient paging in any query, on any
schema, purely in user land, without requiring extra properties or
other schema changes". This means that no extra property is required
for an index, and that you can have efficient pagination for any
existing Model.

The class wraps db.Query to build bookmarkable queries and resume from
query bookmarks.  A  quick example of how to use it:

    # Get the encoded bookmark from request.
    bookmark = request.GET['bookmark']

    # Build a paginated query.
    query = PagerQuery(ModelClass).filter('foo >', 'bar') \
                                  .filter('baz =', 'ding') \
                                  .order('foo')

    # Fetch results for the current page and bookmarks for previous and next
    # pages.
    prev, results, next = query.fetch(10, bookmark)

    # If 'prev' and/or 'next' are returned, use them to create links to the
    # previous and/or next pages.
    http://localhost:8080/?bookmark={{ prev }}
    http://localhost:8080/?bookmark={{ next }}

And here is the code:

    http://bitbucket.org/moraes/appengine/src/4f7036301b52/pager.py

let me know of any issues. :-)

thanks,
rodrigo moraes

[1] 
http://google-appengine.googlegroups.com/web/efficient_paging_using_key_instead_of_a_dedicated_unique_property.txt

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" group.
To post to this group, send email to google-appengine@googlegroups.com
To unsubscribe from this group, send email to 
google-appengine+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to