views:

77

answers:

2

Hi.

See the pagination on the app gallery? It has page numbers and a 'start' parameter which increases with the page number. Presumably this app was made on GAE. If so, how did they do this type of pagination? ATM I'm using cursors but passing them around in URLs is as ugly as hell.

+1  A: 

Ben Davies's outstanding PagedQuery class will do everything that you want and more.

Adam Crossland
+1  A: 

You can simply pass in the 'start' parameter as an offset to the .fetch() call on your query. This gets less efficient as people dive deeper into the results, but if you don't expect people to browse past 1000 or so, it's manageable. You may also want to consider keeping a cache, mapping queries and offsets to cursors, so that repeated queries can fetch the next set of results efficiently.

Nick Johnson
Do you think this is how it is done in the link I posted? I wouldn't have expected them to use something which scales poorly. I'll try the cache idea.
Matt H
Also, how is it possible to show page numbers in GAE?
Matt H
Yes, I expect this is how it's done in the gallery, for the same reason I mentioned - most people don't browse past the first couple of hundred entries. You can show page numbers because you know the offset - just divide by the number of results.
Nick Johnson