[ckan-dev] dataset search and incorrect return value from url_for

Vitor Baptista vitor at vitorbaptista.com
Fri May 2 23:32:42 UTC 2014


Hi Augusto,

Interesting. Could you reproduce it on http://demo.ckan.org? I tried
looking into routing.py to see when we added multiple routes pointing to
controller='package', action='search', and it seems like it was in 2010 in
CKAN 1.3.3 (
https://github.com/ckan/ckan/commit/e1c1f95b2556e95ed6ce17d3bf928b6875194bee),
so there might be something else going on.

Could you open an issue with this e-mail? It's easier for us to track your
bug report.

Cheers,


2014-05-02 15:39 GMT-03:00 Augusto Herrmann <augusto.herrmann at gmail.com>:

> Dear all,
>
> we've been receiving seemingly incorrect results in CKAN 2.2 for the
> ckan.lib.helpers.url_for function. In a template in an extension we're
> developing, for example, the following snippet
>
> {% url_for controller='package', action='search' %}
>
> returns "/dataset/search", when the correct url should be just "/dataset".
> This incorrect behavior also breaks e.g. faceted navigation (which we
> haven't customized, and is the default CKAN one), as all faceted navigation
> links point to, e.g., "/dataset/search?tags=transportation" instead of the
> correct url "/dataset?tags=transportation". That wrong url does reveal a
> search page, however the results of the search are always empty no matter
> what (even with no filters at all).
>
> This affects everywhere url_for is called, e.g. the tag list on /tag
> creates links to "/dataset/search" instead of "/dataset".
>
> Looking into the code, it seems ckan.lib.helpers.url_for [1] wraps around
> a call to routes.url_for [2]. These routes seem to be configured in
> config.routing [3], but apparently search is defined twice, once in
> "/dataset" (L207) and then again in "/dataset/search" (L210-215). Perhaps
> this is a bug causing the problem?
>
> How do we fix this? Sean, do you have any ideas? Any help would be
> appreciated.
>
> [1] https://github.com/ckan/ckan/blob/ckan-2.2/ckan/lib/helpers.py#L110
> [2]
> https://routes.readthedocs.org/en/latest/modules/util.html?highlight=url_for#routes.util.url_for
> [3] https://github.com/ckan/ckan/blob/ckan-2.2/ckan/config/routing.py#L206
>
> Best regards,
> Augusto Herrmann
> Open Data Team - Ministry of Planning - Brazil
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>
>


-- 

Vítor Baptista

Developer  |  http://vitorbaptista.com |
LinkedIn<http://www.linkedin.com/in/vitorbaptista>|
@vitorbaptista <http://twitter.com/vitorbaptista>

The Open Knowledge Foundation <http://okfn.org>

*Empowering through Open Knowledge*

http://okfn.org/  |  @okfn <http://twitter.com/okfn>  |  OKF on
Facebook<https://www.facebook.com/OKFNetwork> |
Blog <http://blog.okfn.org/>  |  Newsletter<http://okfn.org/about/newsletter/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140502/5e5e288a/attachment-0003.html>


More information about the ckan-dev mailing list