I have a similar question, but what I'm interested in is how to deal with a large number of records?
In the previous example if there are thousands of users and paginate ended up with something like 200 pages. Suppose one day I had to do some sort of online report, how do I try not use all the server resources? On Mon, Jun 29, 2009 at 1:24 AM, Mike Orr <[email protected]> wrote: > > On Sun, Jun 28, 2009 at 12:53 AM, kumar<[email protected]> wrote: > > > > Hi Everyone, > > > > I am trying to display all the users present in the mysql database to > > a template in pylons. Can anyone can help me with what I need to do. > > Have you read the Pylons book? http://pylonsbook.com/ It should > help answer questions like this. > > But basically, assuming your model has an ORM class User, you might do > this in your controller: > > import myapp.model as model > import myapp.model.meta as meta > > def show_users(self): > c.users = model.Session.query(User).order_by(User.username) > return render("/users.html") > > And your template might look like: > > <table> > <caption>All users</caption> > <tr><th>Username</th><tr> > % for u in c.users: > <tr><td>u.username</td></tr> > %end for > </table> > > If you have more than a screenful of users, you might want to use > webehlpers.paginate to display a page at a atime. > > -- > Mike Orr <[email protected]> > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
