[ckan-dev] dataset search and incorrect return value from url_for
Augusto Herrmann
augusto.herrmann at gmail.com
Fri May 2 18:39:18 UTC 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140502/8224a4b3/attachment-0002.html>
More information about the ckan-dev
mailing list