I am new to ckan. After successfully installing ckan when I went to use some ckan plugins as an example ckan-basiccharts i am getting ValueError. After some research, I understand it's related to web-assets. In basicchart folder, I change the {%resource ....} to {%asset ..}
ckanext/basiccharts/theme/templates/basechart_view.html in .html file
but I am still getting the same error. Can anyone please explain the logic behind this error and some tricks to get rid of this error?
Traceback (most recent call last):
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware/../../views/resource.py", line 151, in read
return base.render(template, extra_vars)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
return flask_render_template(template_name, **extra_vars)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
return _render(
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/lib/ckan/default/src/ckan/ckanext/datastore/templates/package/resource_read.html", line 1, in <module>
{% ckan_extends %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_read.html", line 3, in <module>
{% set res = resource %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/base.html", line 4, in <module>
{% set dataset_type = dataset_type or pkg.type or 'dataset' %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 1, in <module>
{% extends "base.html" %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/base.html", line 106, in <module>
{%- block page %}{% endblock -%}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 19, in <module>
{%- block content %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 22, in <module>
{% block main_content %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/page.html", line 53, in <module>
{% block pre_primary %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_read.html", line 22, in <module>
{% block resource %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_read.html", line 24, in <module>
{% block resource_inner %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_read.html", line 104, in <module>
{% block data_preview %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_read.html", line 105, in <module>
{% block resource_view %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_read.html", line 118, in <module>
{% block resource_view_content %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/resource_read.html", line 128, in <module>
{% snippet 'package/snippets/resource_view.html',
File "/usr/lib/ckan/default/src/ckan/ckan/lib/jinja_extensions.py", line 274, in _call
return base.render_snippet(*args, **kwargs)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 95, in render_snippet
output = render(template_name, extra_vars=kw)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
return flask_render_template(template_name, **extra_vars)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
return _render(
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/snippets/resource_view.html", line 3, in <module>
{% block resource_view %}
File "/usr/lib/ckan/default/src/ckan/ckan/templates/package/snippets/resource_view.html", line 27, in <module>
{{ h.rendered_resource_view(resource_view, resource, package) }}
File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 2488, in rendered_resource_view
return literal(base.render(template, extra_vars=data_dict))
File "/usr/lib/ckan/default/src/ckan/ckan/lib/base.py", line 151, in render
return flask_render_template(template_name, **extra_vars)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 137, in render_template
return _render(
File "/usr/lib/ckan/default/lib/python3.8/site-packages/flask/templating.py", line 120, in _render
rv = template.render(context)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/ckanext_basiccharts-0.1-py3.8.egg/ckanext/basiccharts/theme/templates/basechart_view.html", line 1, in <module>
{% resource 'basiccharts/main' %}
File "/usr/lib/ckan/default/src/ckan/ckan/lib/jinja_extensions.py", line 334, in _call
h.include_resource(args[0], **kwargs)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/helpers.py", line 2097, in include_resource
import ckan.lib.fanstatic_resources as fanstatic_resources
File "/usr/lib/ckan/default/src/ckan/ckan/lib/fanstatic_resources.py", line 252, in <module>
create_library('vendor', os.path.join(base_path, 'vendor'), depend_base=False)
File "/usr/lib/ckan/default/src/ckan/ckan/lib/fanstatic_resources.py", line 243, in create_library
registry.add(library)
File "/usr/lib/ckan/default/lib/python3.8/site-packages/fanstatic/registry.py", line 18, in add
self[item.name] = item
File "/usr/lib/ckan/default/lib/python3.8/site-packages/fanstatic/registry.py", line 72, in __setitem__
raise ValueError('Registry initialized.')
ValueError: Registry initialized.
For migration to webassets, you need to create an assets folder and place there .js
and .css
files of the extension. In addition, you need to create webassets.yml inside the assets folder where those .js
and .css
files should be registered. This process is described here and here.
But you can use this version of ckanext-basiccharts that is compatible with current ckan versions.