On Thu, Feb 24, 2011 at 10:57 AM, Ben Bangert <b...@groovie.org> wrote:
> On Feb 24, 2011, at 9:43 AM, Gael Pasgrimaud wrote:
>
>> On Thu, Feb 24, 2011 at 6:37 PM, Mike Orr <sluggos...@gmail.com> wrote:
>>> Paginate works with Pyramid, with the caveat that if you use the
>>> Page.pager() method, you have to pass a custom URL generator to the
>>> constructor as described on the webhelpers.paginate page.
>>>
>>
>> Can't we have a default pyramid generator (and well, webob based
>> frameworks) in WebHelpers who use the request.path to generate the url
>> ?
>>
>> So you can use Page.pager(request=request)
>
> Yep, that was the thought for the next iteration.

That's something I hadn't seen, passing a (WebOb-compatible) request
to the pager method rather than to the constructor. That might be a
solution.

> Also, to require the object being paginated to support the Python sequence 
> API, so that the hacky code that tries to deal with various SQLA things isn't 
> needed. Ie, there'd be some sequence wrappers for SQLA query objects vs. a 
> bunch of if/else code toggling it inside the paginator.

I still need to see a more concrete version of what you're thinking
of. The paginator already treats the collection as a sequence as much
as possible.

Also, you were talking about a way to fetch one more record than
required, and using the extra primary key as the starting point for
the next page to avoid the OFFSET clause which is inefficient (because
it has to cycle through all the records before this page). I tried to
do this but I don't see how it would work.

1) We can't figure out which record number we're on without cycling
through the previous records, because it changes depending on the
WHERE clauses.

2) The user would have to pass in the name of the primary key field.

3) You'd have to transmit the last primary key to the next request as
a query param.

2 and 3 are doable, but I don't see how to do 1 without passing a
bunch of state variables to the next page, and the pager may go out of
kilter if these aren't calculated correctly for the receiving page.

-- 
Mike Orr <sluggos...@gmail.com>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-devel" group.
To post to this group, send email to pylons-devel@googlegroups.com.
To unsubscribe from this group, send email to 
pylons-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/pylons-devel?hl=en.

Reply via email to