Hi, Send a parameter named "page" from url like "page=1", "page=2" and handle it in Post method. You can return records from list like result_list[from_indice:to_indice] For example: from_indice = 10 to_indice = 20 It will return records between 10 to 20.
def POST(self): result_list = [bla bla 200 records] i = web.input(page=1) RECORDS = 10 return render.recordslist(result_list[(page - 1) * RECORDS : page * RECORDS]) 2013/2/21 shiva krishna <shivakrsh...@gmail.com> > I am using python `web.py` to design a small web app , here actually i am > not using any database for fetching results/records, i will have a list of > records(which i will get from some where according to requirement :) ) > > Below is my code > > **code.py** > > import web > from web import form > > urls = ( > '/', 'index', > '/urls', 'urls_result', > ) > > app = web.application(urls, globals()) > render = web.template.render('templates/') > > class index: > def GET(self): > return render.home() > > def POST(self): > result_list = [('Images', ' > http://www.google.co.in/imghp?hl=en&tab=wi'), > ('Maps', ' > http://maps.google.co.in/maps?hl=en&tab=wl'), > ('Play', ' > https://play.google.com/?hl=en&tab=w8'), > ('YouTube', ' > http://www.youtube.com/?gl=IN&tab=w1'), > ('News', ' > http://news.google.co.in/nwshp?hl=en&tab=wn'), > ('Gmail', ' > https://mail.google.com/mail/?tab=wm'), > ('Drive', 'https://drive.google.com/?tab=wo'), > ('More»', ' > http://www.google.co.in/intl/en/options/'), > ('Web History', ' > http://www.google.co.in/history/optout?hl=en'), > ('Settings', ' > http://www.google.co.in/preferences?hl=en'), > ('Sign in', ' > https://accounts.google.com/ServiceLogin?hl=en&continue=http://www.google.co.in/' > ), > ('Advanced search', ' > http://www.google.co.in/advanced_search?hl=en-IN&authuser=0'), > .............. > .............. > .............. so on until 200 records ] > return render.recordslist(result_list) > > if __name__ == "__main__": > app.run() > > **home.html** > > $def with() > <html> > <head> > <title>Home Page</title> > <body alink="green" link="blue" > > <div class="main"> > <center> > <form method="POST" action='urls'> > <input class="button" type="submit" name="submit" > value="Submit" /> > </form> > </center> > </div> > </body> > </html> > > **recordslist.html** > > > > > $def with(result_list) > <html> > <head> > <title>List of records</title> > </head> > <body> > <table> > $for link in result_list: > <tr> > <td>$link[0]</td> > <td>$link[1]</td> > </tr> > </table> > </body> > > > So from the above code what i am doing is, when i run the server and hit > the browser with ip returned from `web.py`, it is redirected to home page > (with url `/` and template as `home.html`) which consists of form with a > single button. > > Now here i am not using any `database` to fetch the records, simply i have > hardcored records which are in the form of `list of tuples` as you can see > above. > > So when the user clicks the submit button i displaying the records in the > form of the `table` by directing to the `/url` that renders template > `recordslist.html` > > now the above process is working fine. But here the `list of > tuples/records` may up to `200 or more`, so i want to implement > `pagination` for `/url` page. > > I have googled a lot and all hits are found for retreiving the records > from database, but not from the list, i am really confused on how to > paginate the results with `10 pages for page`. > > So can anyone please let me now how to paginate the results/records from > list from the above code. > > -- > You received this message because you are subscribed to the Google Groups > "web.py" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to webpy+unsubscr...@googlegroups.com. > To post to this group, send email to webpy@googlegroups.com. > Visit this group at http://groups.google.com/group/webpy?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- Aydın Şen -- You received this message because you are subscribed to the Google Groups "web.py" group. To unsubscribe from this group and stop receiving emails from it, send an email to webpy+unsubscr...@googlegroups.com. To post to this group, send email to webpy@googlegroups.com. Visit this group at http://groups.google.com/group/webpy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.