As raw SQL:
SELECT * FROM `books` ORDER BY `title` ASC LIMIT 0, 10
SELECT * FROM `books` ORDER BY `title` ASC LIMIT 10, 20
Using web.db:
db.select('books', order='title', offset=0, limit=10)
db.select('books', order='title', offset=10, limit=20)
see http://webpy.org/cookbook/select
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.
On Sat, Nov 7, 2009 at 6:02 PM, Greg Milby <[email protected]> wrote:
> ah - ty
>
>
> On Sat, Nov 7, 2009 at 7:58 PM, alexander lind <[email protected]>wrote:
>
>> as far as i know.
>>
>> On Nov 7, 2009, at Nov 7, 2009 - 7:56 PM, Greg Milby wrote:
>>
>> what is afaik?
>>
>> On Sat, Nov 7, 2009 at 5:28 PM, Leon Waldman <[email protected]>wrote:
>>
>>> Hi,
>>>
>>> AFAIK, you can do it on the SQL...
>>>
>>> Cheers
>>>
>>> --
>>> Leon Waldman
>>> SysAdmin Linux - Arquiteto de Infra-Estrutura & TI.
>>>
>>>
>>>
>>> On Sat, Nov 7, 2009 at 11:55 PM, Greg Milby <[email protected]> wrote:
>>>
>>>> actually i was trying to learn how to paginate in webpy.
>>>>
>>>>
>>>> On Sat, Nov 7, 2009 at 2:09 PM, Angelo Gladding
>>>> <[email protected]>wrote:
>>>>
>>>>> Can you clarify what it is you mean by "sort them with links"? Are you
>>>>> dealing w/ raw HTML or are you sending an unsorted list to a template?
>>>>>
>>>>>
>>>>> On Sat, Nov 7, 2009 at 7:22 AM, geekbuntu <[email protected]> wrote:
>>>>>
>>>>>>
>>>>>> i have a wicked long list of used books - wondering if i can sort them
>>>>>> with links?
>>>>>>
>>>>>> http://pairadice.no-ip.org:8080/books
>>>>>>
>>>>>> (around 4500)
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>> --
>>>>> Angelo Gladding
>>>>> [email protected]
>>>>> http://angelo.gladding.name/
>>>>> E69E 47E8 5C3A 96E5 C70F
>>>>> D931 F35C ACBA 6F39 9611
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>
> >
>
--
Angelo Gladding
[email protected]
http://angelo.gladding.name/
E69E 47E8 5C3A 96E5 C70F
D931 F35C ACBA 6F39 9611
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---