1

I’ve been working on installing the CKAN Resource Authorizer extension. I’m in the final stages of installation, all I need is to create the necessary tables in the database using and to reindex the CKAN metadata in SOLR using the following commands, as per the installation instructions, in the python environment:

$ paster --plugin=ckanext-resourceauthorizer resourceauthorizer initdb --config=/etc/ckan/default/production.ini

$ paster --plugin=ckan search-index rebuild --config=/etc/ckan/default/production.ini

There are no issues when I run (see below output): paster --plugin=ckanext-resourceauthorizer resourceauthorizer initdb --config=/etc/ckan/default/ckan.ini

2021-07-29 10:50:09,931 INFO  [ckan.cli] Using configuration file /etc/ckan/default/ckan.ini
2021-07-29 10:50:09,931 INFO  [ckan.config.environment] Loading static files from public
2021-07-29 10:50:10,023 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:50:10,601 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:50:10,895 DEBUG [ckanext.harvest.model] Harvest tables defined in memory
2021-07-29 10:50:10,914 DEBUG [ckanext.harvest.model] Harvest tables already exist
2021-07-29 10:50:11,070 INFO  [ckan.config.environment] Loading static files from public
2021-07-29 10:50:11,179 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:50:11,372 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:50:11,403 DEBUG [ckanext.harvest.model] Harvest tables already exist

resource_acl table created

However, I get the below error when I run: paster --plugin=ckan search-index rebuild --config=/etc/ckan/default/ckan.ini

Command 'search-index' not known (you may need to run setup.py egg_info)
Known commands:
  create       Create the file layout for a Python distribution
  exe          Run #! executable files
  help         Display help
  make-config  Install a package and create a fresh config file/directory
  points       Show information about entry points
  post         Run a request for the described application
  request      Run a request for the described application
  serve        Serve the described application
  setup-app    Setup an application, given a config file

As such, as per CKAN 2.9, I ran this command instead with no issues (see below output): ckan --config=/etc/ckan/default/ckan.ini search-index rebuild

2021-07-29 10:51:28,143 INFO  [ckan.cli] Using configuration file /etc/ckan/default/ckan.ini
2021-07-29 10:51:28,144 INFO  [ckan.config.environment] Loading static files from public
2021-07-29 10:51:28,254 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:51:28,816 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:51:28,888 DEBUG [ckanext.harvest.model] Harvest tables defined in memory
2021-07-29 10:51:28,904 DEBUG [ckanext.harvest.model] Harvest tables already exist
2021-07-29 10:51:29,318 INFO  [ckan.lib.search] Rebuilding search index...
2021-07-29 10:51:29,322 INFO  [ckan.lib.search] Rebuilding the whole index...
Indexing dataset 6/62021-07-29 10:51:31,074 INFO  [ckan.lib.search] Finished rebuilding search index.
2021-07-29 10:51:31,626 INFO  [ckan.lib.search] Commited pending changes on the search index

At this point, everything seems to be set up but unfortunately when I run CKAN and click on the "manage" button of a resource in a dataset I get the following error (prompted in the ckan console)

  File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 89, in block 'primary_content'
    {% block page_header %}
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 97, in block 'page_header'
    {% block content_primary_nav %}{% endblock %}
  File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_edit_base.html", line 25, in block 'content_primary_nav'
    {% block inner_primary_nav %}{% endblock %}
  File "/usr/lib/ckan/default/src/ckanext-resourceauthorizer/ckanext/resourceauthorizer/templates/package/resource_edit_base.html", line 5, in block 'inner_primary_nav'
    {{ h.build_nav_icon('resource_acl', _('Resource ACL'), dataset_id=pkg.name, resource_id=res.id) }}
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 1052, in build_nav_icon
    return _make_menu_item(menu_item, title, **kw)
  File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 1130, in _make_menu_item
    raise Exception('menu item `%s` cannot be found' % menu_item)
Exception: menu item `resource_acl` cannot be found

I am not sure why this error occurs since the first paster command appeared to create the resource_acl ("resource_acl table created"). As per CKAN 2.9, I tried running the following command instead: ckan --config=/etc/ckan/default/ckan.ini resourceauthorizer initdb

But I got the following error:

2021-07-29 10:56:21,448 INFO  [ckan.cli] Using configuration file /etc/ckan/default/ckan.ini
2021-07-29 10:56:21,448 INFO  [ckan.config.environment] Loading static files from public
2021-07-29 10:56:21,536 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:56:22,071 INFO  [ckan.config.environment] Loading templates from /usr/lib/ckan/default/src/ckan/ckan/templates
2021-07-29 10:56:22,499 DEBUG [ckanext.harvest.model] Harvest tables defined in memory
2021-07-29 10:56:22,515 DEBUG [ckanext.harvest.model] Harvest tables already exist
Usage: ckan [OPTIONS] COMMAND [ARGS]...

Error: No such command 'resourceauthorizer'.

It appears that CKAN does not recognise resourceauthorizer as a command (but paster did recognise it). This is possibly because the extension was written for CKAN 2.7.3. Any help or advice on how to resolve this issue would be greatly appreciated. Or, is there guidance on updating older extensions for newer versions of CKAN? Thanks!

Jardel Lucca
  • 1,115
  • 3
  • 10
  • 19
LD-Win
  • 11
  • 2

1 Answers1

1

With CKAN 2.9 and migraton to flask, CLI commands are using click and your command should be migrated and reregistered as click command

Here is a guide how to migrate your extension https://github.com/ckan/ckan/wiki/Python-3-migration-guide-for-extensions

tino097
  • 389
  • 1
  • 8