On Saturday 03 February 2007 08:01, dds wrote:
> Thanks for looking into the pagination stuff.

No hope too soon. :)

> On Jan 29, 11:54 pm, Christoph Haas <[EMAIL PROTECTED]> wrote:
> > The documentation
> > athttp://pylonshq.com/WebHelpers/module-webhelpers.pagination.htmlcont
> >ains this example:
> >
> >   # In this case, Person is a SQLObject class, or it could be a
> > list/tuple person_paginator, person_set = paginate(Person, page=1)
> >
> > It wasn't very clear to me how that is supposed to work with
> > SQLAlchemy. It must look like this:
> >
> >   person_paginator, person_set = \
> >     h.pagination.paginate(model.Person.select())
> >
> > Can we please add that example to the the webhelpers/pagination/orm.py
> > module?
>
> But this is exactly what the paginator is supposed to avoid when using
> an ORM. You're selecting every person from the database, pulling it
> into memory, and making the paginator chunk it up.

Are you sure? In the background the orm.py is creating a lazy mapping that 
is only requesting rows from the database when they are needed. As far as 
I understand even that .select() doesn't pull anything unless you read 
from it. And if you read just a slice the database would *then* start a 
query with a certain LIMIT.

> The point of giving 
> it a real query object is that it should use limit and offset to
> select only the elements from the DB to make the current page, not
> carry it all around in memory.

True, but isn't that also true for .select()? I'm really not sure because 
I'm a newbie to SQLAlchemy. Of course a "nakes .select()" is bullshit 
because it does not contain any selection criteria.

By the way... does anyone know if there's an easier way to create a query 
than the long prayer version: model.session_context.current.query() ?

Cheers
 Christoph

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to