On Wed, Apr 29, 2009 at 12:36 AM, Clemens Hermann <goo...@clhe.de> wrote:
>> You could put a paginate subclass under
>> webhelpers.pylons, which would keep the Pylons-specific code separate
>> from the generic code.
>
> currently there is no dependency on pylons but on routes (or did I
> miss a nested dependency?).

I'm hoping to get rid of that too but it's needed for backward
compatibility.  (It's the url_for import.)

> As long as routes is used either with route memory or alternatively
> has the mapper_dict attribute set, the path variables used by url_for
> are taken from there.
> So we no longer depend on route memory here but the paginator will
> respect it in case it is present.
> If neither route memory nor mapper_dict is present the paginator takes
> arbitrary keyword arguments on instantiation and forwards those to
> url_for.
> the latter allows for using the paginator outside pylons.

The thing is, this is a back door dependency.  WebHelpers claims to be
standalone but it actually depends on Routes in a couple places, due
to the assumption that url_for would always be available.  And url_for
uses a singleton hack to get the current URL, because it's outside the
WSGI chain, as is Paginate.    That's the magic.

With url(), the RoutesMiddleware (which legitimately knows the current
URL) instantiates a URLGenerator and puts it in the WSGI environent,
and then Pylons puts it onto pylons.url.  But Paginate doesn't have
access to it unless Pylons gives it to it, which it doesn't.
(Although maybe one could in the constructor?)

Anyway, I'd be more in favor of getting the navigator out of Paginate,
so that it's not doing this url_for backdoor.

>
>> I think Ben told me url() uses route memory in one situation but not
>> in another, but i can't remember what those are.
>
> maybe you refer to the fact that route memory works for url_for but
> not for redirect_to?

No, it's both in url().  Maybe it's just that url.current() uses route
memory but url() doesn't.

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