Thoughts on pagination with GAE

43 views
Skip to first unread message

wings

unread,
Nov 6, 2009, 5:55:12 PM11/6/09
to Google App Engine
Hello App Engine users!

I'm working on a small project that required pagination.

I found the pagination article on the app engine site[1], and it was
helpful. But when I was done implementing the approach described, I
was left with an extra layer of complication, ugly urls, and not even
a 'previous page' link.

So I put my thoughts together here: http://www.gomuse.com/pagination-by-date-with-google-app-engine-0

Please let me know what you think.

What I would really like to discover is a solution that is:
- efficient
- gives me a list of page numbers
- gives me a 'first page' and a 'last page' link


[1]: http://code.google.com/appengine/articles/paging.html

Joshua Smith

unread,
Nov 6, 2009, 7:23:44 PM11/6/09
to google-a...@googlegroups.com
I use a simple trick for Previous Page: onclick="history.go(-1)"

Also, instead of passing the date, you can pass the ID of the next object, and fetch it's date to figure out where to start.  That will eliminate all the encoding/decoding of dates stuff.

-Joshua

wings

unread,
Nov 6, 2009, 9:39:51 PM11/6/09
to Google App Engine
I really like that previous page trick -- thanks!

I'd rather not pass the ID of the next object because then I'd have to
do a datastore get in order to get its date.

It's definitely a good idea, especially since the encoding/decoding is
a hassle -- and it would get around the downside that I mentioned
(i.e. two entries posted at the same time wouldn't be a problem). I'll
consider it -- thanks!

Joshua Smith

unread,
Nov 7, 2009, 8:18:10 AM11/7/09
to google-a...@googlegroups.com
> I'd rather not pass the ID of the next object because then I'd have to
> do a datastore get in order to get its date.

Memcache!

Barry Hunter

unread,
Nov 7, 2009, 9:19:27 AM11/7/09
to google-a...@googlegroups.com
2009/11/6 wings:

>
>
> What I would really like to discover is a solution that is:

... wouldnt we all! I'm not sure its been determined that a 'true'
solution exists. ;P

Or at least a simple one. And one that works on massive datasets, like
AppEngine is meant to support.


Coming from mysql, its easy to think paging is a simple issue. Just
use a Count(*) and LIMIT on the queries. But that doesn't scale, its
horribly slow (but usually fast enough on small datasets)


In fact it reminds me of a saying I recently saw in a book:
"Fast, Accurate, Simple: pick any two"


Also re the 'previous' page link, memcache (again)! Store the 'cursor'
of each page in memcache (as you calculate it), and then on a page,
you can check memcache for cursor you need for the back link.

Reply all
Reply to author
Forward
0 new messages