0
votes

I recently made my first plugin using the IBlueprint interface, and have been using it successfully on CKAN 2.8. I attempted to deploy it to a system running 2.7.6 (we have postponed updating to 2.8 until a couple other items are ready, but though this would drop in) and encountered an issue with the build_nav_icon template helper function.

We are trying to add a dataset navigation menu entry, and the function call within my read_base.html template is:

h.build_nav_icon('relationships.read', _('Relationships'), dataset_id=pkg.name, icon='connectdevelop')

relationships.read links to a blueprint entry, and this all works on 2.8, but 2.7 returns:

File '/usr/lib/ckan/default/src/ckanext-relationshipdisplay/ckanext/relationshipdisplay/templates/package/read_base.html', line 5 in block "content_primary_nav" {{ h.build_nav_icon('relationships.read', _('Relationships'), dataset_id=pkg.name, icon='connectdevelop')}}

File '/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py', line 672 in build_nav_icon return _make_menu_item(menu_item, title, **kw)

File '/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py', line 729 in _make_menu_item raise Exception('menu item %s cannot be found' % menu_item)

Exception: menu item relationships.read cannot be found

Looking at the CKAN code a bit it appears the make_menu_item function only references pylons based routes. Is there a workaround to make this work on 2.7 or something I may have overlooked in my plugin configuration?

1

1 Answers

1
votes

For CKAN 2.7 you need create and connect the controller like in https://github.com/ckan/ckan/blob/2.7/ckanext/datastore/controller.py and https://github.com/ckan/ckan/blob/2.7/ckanext/datastore/plugin.py#L157

from ckan.plugins.toolkit import BaseController

class RelationshipdisplayController(BaseController):
  def someactionhere(self):
    return ''

  def before_map(self, m):
            'relationships.read', '/someurlhere',
            controller='ckanext.relationshipdisplay.controller.RelationshipdisplayController',
            action='someactionhere', ckan_icon='connectdevelop')
        return m

EDIT:

Reason for implementing pylons based controller is that most of the flask support in 2.7 does not exist yet. The only migrated controller in the core is the api and that doesn't require pretty much anything from the helpers.