Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor metadata profile rendering logic to improve conditional checks for GeoDCAT-AP/INSPIRE (spatial datasets) profiles #117

Merged
merged 3 commits into from
Nov 14, 2024

Conversation

mjanez
Copy link
Owner

@mjanez mjanez commented Nov 13, 2024

Fixes

  • ckanext/schemingdcat/validators.py: The 'staticmethod' object is not callable' error occurs because the @staticmethod' decorator is used outside the context of a class (normalize_string) . The `@staticmethod' decorator only makes sense when applied to methods defined inside a class, as it makes the method static, allowing it to be called without instantiating the class.

Refinements to metadata profiles display logic:

  • ckanext/schemingdcat/templates/schemingdcat/package/snippets/download_metadata.html: Updated the condition to display the RDF DCAT Endpoint only if certain profiles are present and specific conditions are met.
  • ckanext/schemingdcat/templates/schemingdcat/package/snippets/metadata_profiles_badges.html: Added a check to ensure geodcat_ap profiles are displayed only if the package's dcat_type is in inspire_metadata_values.

Code cleanup:

  • ckanext/schemingdcat/templates/schemingdcat/package/snippets/metadata_profiles_badges.html: Removed the unnecessary has_geodcat_ap variable and the redundant loop that checked for dcat_ap profiles.

…ks for GeoDCAT-AP/INSPIRE (spatial datasets) profiles
@mjanez mjanez added bug Something isn't working enhancement New feature or request labels Nov 13, 2024
@mjanez mjanez added this to the v4.2.3 milestone Nov 13, 2024
@mjanez mjanez self-assigned this Nov 13, 2024
…and error handling

2024-11-13 23:29:37,091 DEBUG [ckanext.schemingdcat.statistics.model] SchemingDCAT statistics table dropped from DB
2024-11-13 23:29:37,108 DEBUG [ckanext.schemingdcat.statistics.model] SchemingDCAT statistics table defined in DB
Traceback (most recent call last):
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
psycopg2.errors.DuplicateTable: relation "schemingdcat_statistics" already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/etc/ckan/default/wsgi.py", line 20, in <module>
    application = make_app(config)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/middleware/__init__.py", line 27, in make_app
    load_environment(conf)
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 69, in load_environment
    p.load_all()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 222, in load_all
    load(*plugins)
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 253, in load
    plugins_update()
  File "/usr/lib/ckan/default/src/ckan/ckan/plugins/core.py", line 210, in plugins_update
    environment.update_config()
  File "/usr/lib/ckan/default/src/ckan/ckan/config/environment.py", line 227, in update_config
    plugin.configure(config)
  File "/usr/lib/ckan/default/src/ckanext-schemingdcat/ckanext/schemingdcat/plugin.py", line 259, in configure
    sdct_model.clean()
  File "/usr/lib/ckan/default/src/ckanext-schemingdcat/ckanext/schemingdcat/statistics/model.py", line 69, in clean
    setup()
  File "/usr/lib/ckan/default/src/ckanext-schemingdcat/ckanext/schemingdcat/statistics/model.py", line 49, in setup
    statistics_table.create()
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/sql/schema.py", line 960, in create
    bind._run_ddl_visitor(ddl.SchemaGenerator, self, checkfirst=checkfirst)
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 3228, in _run_ddl_visitor
    conn._run_ddl_visitor(visitorcallable, element, **kwargs)
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 2211, in _run_ddl_visitor
    visitorcallable(self.dialect, self, **kwargs).traverse_single(element)
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/sql/visitors.py", line 524, in traverse_single
    return meth(obj, **kw)
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 895, in visit_table
    self.connection.execute(
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1380, in execute
    return meth(self, multiparams, params, _EMPTY_EXECUTION_OPTS)
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/sql/ddl.py", line 80, in _execute_on_connection
    return connection._execute_ddl(
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1472, in _execute_ddl
    ret = self._execute_context(
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1943, in _execute_context
    self._handle_dbapi_exception(
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 2124, in _handle_dbapi_exception
    util.raise_(
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/util/compat.py", line 208, in raise_
    raise exception
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1900, in _execute_context
    self.dialect.do_execute(
  File "/usr/lib/ckan/default/lib64/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute
    cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.DuplicateTable) relation "schemingdcat_statistics" already exists

[SQL:
CREATE TABLE schemingdcat_statistics (
	id TEXT NOT NULL,
	stat_count INTEGER NOT NULL,
	stat_type TEXT NOT NULL,
	value TEXT NOT NULL,
	icon TEXT,
	label TEXT,
	PRIMARY KEY (id)
)

]
(Background on this error at: https://sqlalche.me/e/14/f405)
unable to load app 0 (mountpoint='') (callable not found or import error)
…tion

The `'staticmethod' object is not callable' error occurs because the `@staticmethod' decorator is used outside the context of a class. The `@staticmethod' decorator only makes sense when applied to methods defined inside a class, as it makes the method static, allowing it to be called without instantiating the class.
@mjanez mjanez merged commit eaed7c9 into main Nov 14, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant