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.
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
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.
> 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.
> 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
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!
> 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.