> Try something like this:
>
> paths = ('/books', 'Books')
> app = web.application(paths, globals())
>
> class Books:
> def GET(self):
> """
> >>> assert app.request('/books?p=4').status == '200 OK'
>
> """
> try:
> offset = web.input('p').p * 10
> except web.badrequest:
> return list(db.select('books', order='title'))
> return list(db.select('books', order='title', offset=offset, limit=10))
>
> Let me know if that helps.
Small correction.
web.input('p').p returns a string. It must be converted to int before
multiplying with 10.
Also p must be optional parameter.
try:
p = int(web.input(p=0).p)
except ValueError:
p = 0
offset = p*10
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web.py" 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/webpy?hl=en
-~----------~----~----~----~------~----~------~--~---