Question: can anybody provide a working implementation of pagination using cursors? 

Most examples are about how to access the next pages. I am having trouble accessing previous pages.

Answer: 
```
def get(self):
    echo = self.response.out.write
    limit = 10
    if self.is_logged_in():
        curs = Cursor(urlsafe=self.request.get('curs'))

        query = Postdb.query()

        if self.request.get('type') == 'prev':
            query_reverse = query.order(-Postdb.key)

            posts, cursor, more = query_reverse.fetch_page(limit, start_cursor=curs.reversed())

            echo('<ol>')
            for post in reversed(posts):
                echo('<li><a href="'+post.key.urlsafe()+'">'+post.title+'</a></li>')
            echo('</ol>')

            if more and cursor:
                echo('<a href="?type=prev&curs='+cursor.reversed().urlsafe()+'">prev</a> ')

            echo('<a href="?type=next&curs='+curs.urlsafe()+'">next</a>')
        else:
            query_forward = query.order(Postdb.key)

            posts, cursor, more = query_forward.fetch_page(limit, start_cursor=curs)

            echo('<ol>')
            for post in posts:
                echo('<li><a href="'+post.key.urlsafe()+'">'+post.title+'</a></li>')
            echo('</ol>')

            if self.request.get('curs') != '':
                echo('<a href="?type=prev&curs='+curs.urlsafe()+'">prev</a> ')

            if more and cursor:
                echo('<a href="?type=next&curs='+cursor.urlsafe()+'">next</a>')

        echo('<br><br><a href="/auth/posts/list">start</a>')

```
If you have only a limited number of different queries, you might want to look at

<https://bitbucket.org/viur/server/src/1b739a5e4ff1c2e3ce8933603a6faf32b364e708/indexes.py?at=master>

This class handles all the cursor stuff for you and allows efficient random access to pages (ie. you can directly jump to page n, instead of having to click "next" n times).