[ckan-dev] CkanUrlException when calling controller 'package'

Neuvonen Samuli samuli.neuvonen at ymparisto.fi
Thu Dec 13 07:56:29 UTC 2018


Dear all,

In a template of my custom theme (plugin) I call the helper function url_for like this:

{% set basehref = h.url_for(controller='package', action='new') %}

This works fine on an older ckan-instance but now that I installed a new one, this line gives an error:

File "/usr/lib/ckan/default/src/ckanext-theme-syke/ckanext/syke_theme/templates/package/search.html", line 3, in top-level template code
    {% set basehref = h.url_for(controller='package', action='new') %}
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 342, in url_for
    return _local_url(my_url, locale=locale, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 545, in _local_url
    raise ckan.exceptions.CkanUrlException(error)
CkanUrlException: There is a broken url being created {'action': 'new', 'controller': 'package'}

Looking at the helpers.py code, the error is apparently triggered by this bit in function _local_url:

if url == '/packages':
        error = 'There is a broken url being created %s' % kw
        raise ckan.exceptions.CkanUrlException(error)

But why? And how to get around it?

There was an earlier discussion on the list about a similar error message resulting from not calling a custom controller with a full name, but somehow I think there is probably something else going on here, since the same code works on another instance. Also, I'm not sure what the full name for a ckan-core controller would be. ckan.controllers.package:PackageController?

Thanks for any ideas,
Sam



More information about the ckan-dev mailing list