CKAN 2.9 ValueError: Registry initialized :: ckan basic-charts plugins

CKAN 2.9 ValueError: Registry initialized :: ckan basic-charts plugins

我是 ckan 的新手。当我使用一些 ckan 插件作为示例 ckan-basiccharts 成功安装 ckan 后,我收到了 ValueError。经过一些研究,我了解到它与网络资产有关。在 basicchart 文件夹中,我将 {%resource ....} 更改为 {%asset ..}

ckanext/basiccharts/theme/templates/basechart_view.html 在 .html 文件

但我仍然遇到同样的错误。任何人都可以解释这个错误背后的逻辑和一些摆脱这个错误的技巧吗?

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.

要迁移到 webassets,您需要创建一个资产文件夹并将扩展的 .js.css 文件放在那里。此外,您需要在 assets 文件夹中创建 webassets.yml,其中应注册 .js.css 文件。此过程描述为 here and here

但是您可以使用与当前 ckan 版本兼容的 this 版本的 ckanext-basiccharts。