I asked the question at StackOverflow and there was a good answer but I still could not make it work: http://stackoverflow.com/questions/4840731/how-to-use-cursor-for-pagination
Nick Johnson has a blog post about it but it is more about the source code than a practical example: http://blog.notdot.net/2010/02/New-features-in-1-3-1-prerelease-Cursors. Can anyone explain to me how cursor works for pagination? Thanks! This is the code I am using: items = db.GqlQuery("SELECT * FROM Item ORDER BY date DESC LIMIT 30") #===========adding cursor here===========# cursor = self.request.get("cursor") if cursor: query.with_cursor(cursor) items = query.fetch(30) cursor = query.cursor() #===========adding cursor here===========# #===========regular output===========# self.response.out.write("<ol>") for item in items: self.response.out.write("""<li> <a href="/vote/%s?type=%s"> ^ </a><a href="%s"><span id="large">%s</span></a> <span id='Small'>(%s)</span> <br /> %s<br /> <span id='Small'> %s points %s by %s <a href="/item/%s"></a> | <a href="/item/%s#disqus_thread"></a> </span> </li><br /> """ % (str(item.key().id()), merchandise_type, item.url, item.title, urlparse(item.url).netloc, item.summary, item.points, item.date.strftime("%B %d, %Y %I:%M%p"), item.user_who_liked_this_item, str(item.key().id()), str(item.key().id()))) self.response.out.write("</ol>") #===========regular output===========# #===========link to cursor===========# self.response.out.write("""<a href="/dir?type=%s?cursor= %s">Next Page</a>""" % (merchandise_type, cursor)) -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
