web2py AlterEgo
rock solid framework for agile and secure web applications
home
search
Edit page
Title:
Security Code:
Body:
(use
this
wiki markup)
Based on : http://mdp.cti.depaul.edu/AlterEgo/default/show/63 This example improves on the previous one by calculating the total number of records beforehand. It provides positional feedback to the user, and avoids displaying an empty list at the end. def show_records(): totalrecs = db.executesql('select count(*) from table')[0][0] # number of records in table (for example) showlines = 25 # number of records per page if len(request.args): page=int(request.args[0]) else: page=0 query=db.table.id>0 ### for example (all records in table) rows=db(query).select(limitby=(page,page+showlines)) backward=A('<< previous',_href=URL(r=request,args=[page-showlines])) if page else '<< previous' forward=A('next >>',_href=URL(r=request,args=[page+showlines])) if totalrecs>page+showlines else 'next >>' nav= "Showing %d to %d out of %d records" % (page+1, page+len(rows), totalrecs) return dict(rows=rows,backward=backward,forward=forward, nav=nav)
Resources
Home
Version 1.51 (2008-11-19 14:48:02)
Examples
|
API
|
ORM
Compare
|
Django
|
TG
|
Rails
|
PHP
|
Java
Tutorial
|
Book
|
epydocs
Screencast short
|
long
|
shell
|
GAE
Online Demo
Interactive FAQ (AlterEgo)
Repository of free web2py apps
KPAX (the web2py CMS)
Model Builder
|
Layout Builder
Central Authentication Service
Users Group (free to join)
Development Trunk (svn)
Contact
Massimo Di Pierro
School of Computing
DePaul University
243 S. Wabash Ave
Chicago, IL 60604 (USA)
mdipierro@cs.depaul.edu