Random ...
 
December 2017
S M T W T F S
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Tags ...
Links



Life and all the rest:::: paging appengine query results
Posted at 28.Feb,2010 19:59  Comments 0 / Trackbacks 0 / Like this post!
Technorati tag(s):

Here's how to page reults from appengine query:

  • get pager helper file
  • i had to comment out the check for is issubclass since there's no db.polymodel.Polymodel. I haven't checked out whether there exists polymodel. It works for me since I subclass db.Model
  • add these in my request handler:
            tt_query = PagerQuery(TekaTeki).order('-dcreated')
            prev, results, next = tt_query.fetch(1, bookmark)
    
            template_values = {'entry': results[0],
                                'next': next,
                                'prev': prev
                            }
            path = os.path.join(os.path.dirname(__file__), 'index.html')
            self.response.out.write(template.render(path, template_values))
    
  • and in my index.html:
      {% if prev %}<a href="/?bookmark={{ prev }}">prev</a> {% endif %}| {% if next %}
    <a href="/?bookmark={{ next }}">next</a>{% endif %}
    

and we can now page through" the results accordingly.


Bookmark and Share

Is this entry helpful? Comments/Donate/Click some google ads.  
Trackback is http://myzope.kedai.com.my/blogs/kedai/246/tbping 

Comments
Post a comment