On Tue, Dec 7, 2010 at 8:44 AM, Joel <[email protected]> wrote:
> Hello Pylons experts,
>
> Suddenly webhelpers pagination has become broken in my app (i.e., this
> was working before).  As soon as a page requires pagination, I now get
> the following error:
>
> GenerationException: url_for could not generate URL. Called with args:
> () {'page': 2}
>
> 20 <a href="${url(controller='export', action='options',
> id='lastsearch')}" class="buttonLink" title="export all search result
> Forms; you will be asked to choose a format">export all</a>
> 21 </div>
> 22
> 23 <p id="paginatorPager">${ c.paginator.pager('$link_first
> $link_previous $first_item to $last_item of $item_count $link_next
> $link_last') }</p>
> 24
>
> /Users/user/env-2.6-1.0/lib/python2.6/site-packages/Routes-1.12.3-
> py2.6.egg/routes/util.py, line 269:
> (args, kargs))
>
> /Users/user/env-2.6-1.0/lib/python2.6/site-packages/WebHelpers-0.6.4-
> py2.6.egg/webhelpers/paginate.py, line 597:
> link_url = url_for(**link_params)
>
> /Users/user/env-2.6-1.0/lib/python2.6/site-packages/WebHelpers-0.6.4-
> py2.6.egg/webhelpers/paginate.py, line 703:
> _pagerlink(self.last_page, symbol_last) or '',
>
> /Users/user/app/app/templates/derived/form/results.html, line 23:
> <p id="paginatorPager">${ c.paginator.pager('$link_first
> $link_previous $first_item to $last_item of $item_count $link_next
> $link_last') }</p>
>
> I'm quite certain that I have replaced url_for() with url.current()
> throughout my code.  And I haven't changed form/results.html for a
> long time.

Did you upgrade anything recently? You're using WebHelpers 0.6.4 so is
this a Pylons 0.9.7 application? My most likely guess is that the
route singleton that url_for depends on is not being initialized. It
was always set until Pylons 1.0 and a recent Routes version, but maybe
it's defaulting to disabled now. Check the Routes line in
middleware.py and try this:

app = RoutesMiddleware(app, config['routes.map'], singleton=True)

(Keep any other arguments if there are any.)

If that doesn't work, you can try installing the current version of
WebHelpers. It has been patched to work with pylons.url.current(), or
fall back to url_for() if the former isn't available. The Paginate in
WebHelpers 0.6.4 understands only url_for().

Otherwise, if you have upgraded anything, you may have to re-downgrade
it or make a pure Pylons 0.9.7 virtualenv for your application.

By the way, I have never been happy with the url/url_for() call buried
in the Page.pager() method. Since neither is compatible with Pyramid,
I've been talking with Ben and Christoph Haas about adding yet another
layer that would get the current URL from the constructor as a string
or by passing in WebOb.Request, which would make it more
framework-neutral. We can also merge other query params rather than
dropping them as paginate does now. But Ben is also considering a
refactored paginator for Pyramid, and leaving the one in WebHelpers as
is.

-- 
Mike Orr <[email protected]>

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