reverse cursor

Showing 1-2 of 2 messages
reverse cursor John Tantalo 9/28/11 10:30 AM
I stumbled on a recipe to reverse a cursor, thought others might be
interested.

> from google.appengine.datastore import datastore_query
>
> def reverse(cursor):
>  return datastore_query.Cursor.from_websafe_string(cursor).reversed().to_websafe_string()

This can be used to easily implement previous/next pagination.

Example usage: https://github.com/tantalor/emend/blob/365f62b6e42127f29f24db043349d56fb76e315b/app/handlers/users/default.py
Re: reverse cursor Sylvain 10/1/11 1:25 AM
I use this : http://code.google.com/p/he3-appengine-lib/source/browse/trunk/src/he3/db/tower/paging.py

Easy to go forward, backward and jump from page x to y.