From 482bb1b63cbf874e690099fc98d9aa6b8629091e Mon Sep 17 00:00:00 2001 From: seitenbau-govdata Date: Fri, 21 Apr 2023 17:21:13 +0200 Subject: [PATCH] Drop pylons support --- ckanext/dcat/plugins/__init__.py | 33 ++++++++++++----- ckanext/dcat/plugins/flask_plugin.py | 30 ---------------- ckanext/dcat/plugins/pylons_plugin.py | 52 --------------------------- ckanext/dcat/processors.py | 8 ----- 4 files changed, 24 insertions(+), 99 deletions(-) delete mode 100644 ckanext/dcat/plugins/flask_plugin.py delete mode 100644 ckanext/dcat/plugins/pylons_plugin.py diff --git a/ckanext/dcat/plugins/__init__.py b/ckanext/dcat/plugins/__init__.py index a60269e6..8a55da58 100644 --- a/ckanext/dcat/plugins/__init__.py +++ b/ckanext/dcat/plugins/__init__.py @@ -6,12 +6,11 @@ from ckantoolkit import config from ckan import plugins as p -try: - from ckan.lib.plugins import DefaultTranslation -except ImportError: - class DefaultTranslation(object): - pass +from ckan.lib.plugins import DefaultTranslation + +import ckanext.dcat.blueprints as blueprints +import ckanext.dcat.cli as cli from ckanext.dcat.logic import (dcat_dataset_show, dcat_catalog_show, @@ -21,8 +20,6 @@ class DefaultTranslation(object): ) from ckanext.dcat import utils -from ckanext.dcat.plugins.flask_plugin import MixinDCATPlugin, MixinDCATJSONInterface - CUSTOM_ENDPOINT_CONFIG = 'ckanext.dcat.catalog_endpoint' TRANSLATE_KEYS_CONFIG = 'ckanext.dcat.translate_keys' @@ -31,7 +28,7 @@ class DefaultTranslation(object): I18N_DIR = os.path.join(HERE, u"../i18n") -class DCATPlugin(MixinDCATPlugin, p.SingletonPlugin, DefaultTranslation): +class DCATPlugin(p.SingletonPlugin, DefaultTranslation): p.implements(p.IConfigurer, inherit=True) p.implements(p.ITemplateHelpers, inherit=True) @@ -39,6 +36,18 @@ class DCATPlugin(MixinDCATPlugin, p.SingletonPlugin, DefaultTranslation): p.implements(p.IAuthFunctions, inherit=True) p.implements(p.IPackageController, inherit=True) p.implements(p.ITranslation, inherit=True) + p.implements(p.IClick) + p.implements(p.IBlueprint) + + # IClick + + def get_commands(self): + return cli.get_commands() + + # IBlueprint + + def get_blueprint(self): + return [blueprints.dcat] # ITranslation @@ -123,9 +132,15 @@ def set_titles(object_dict): return data_dict -class DCATJSONInterface(MixinDCATJSONInterface, p.SingletonPlugin): +class DCATJSONInterface(p.SingletonPlugin): p.implements(p.IActions) p.implements(p.IAuthFunctions, inherit=True) + p.implements(p.IBlueprint) + + # IBlueprint + + def get_blueprint(self): + return [blueprints.dcat_json_interface] # IActions diff --git a/ckanext/dcat/plugins/flask_plugin.py b/ckanext/dcat/plugins/flask_plugin.py deleted file mode 100644 index 7b1b6130..00000000 --- a/ckanext/dcat/plugins/flask_plugin.py +++ /dev/null @@ -1,30 +0,0 @@ -# -*- coding: utf-8 -*- - -import ckan.plugins as p - -import ckanext.dcat.cli as cli -import ckanext.dcat.blueprints as blueprints - - -class MixinDCATPlugin(p.SingletonPlugin): - p.implements(p.IClick) - p.implements(p.IBlueprint) - - # IClick - - def get_commands(self): - return cli.get_commands() - - # IBlueprint - - def get_blueprint(self): - return [blueprints.dcat] - - -class MixinDCATJSONInterface(p.SingletonPlugin): - p.implements(p.IBlueprint) - - # IBlueprint - - def get_blueprint(self): - return [blueprints.dcat_json_interface] diff --git a/ckanext/dcat/plugins/pylons_plugin.py b/ckanext/dcat/plugins/pylons_plugin.py deleted file mode 100644 index 93848341..00000000 --- a/ckanext/dcat/plugins/pylons_plugin.py +++ /dev/null @@ -1,52 +0,0 @@ -# -*- coding: utf-8 -*- - -from ckantoolkit import config -import ckan.plugins as p - -import ckanext.dcat.utils as utils - -class MixinDCATPlugin(p.SingletonPlugin): - p.implements(p.IRoutes, inherit=True) - - # IRoutes - - def before_map(self, _map): - - controller = 'ckanext.dcat.controllers:DCATController' - - if p.toolkit.asbool(config.get(utils.ENABLE_RDF_ENDPOINTS_CONFIG, True)): - - _map.connect('dcat_catalog', - config.get('ckanext.dcat.catalog_endpoint', - utils.DEFAULT_CATALOG_ENDPOINT), - controller=controller, action='read_catalog', - requirements={'_format': 'xml|rdf|n3|ttl|jsonld'}) - - _map.connect('dcat_dataset', '/dataset/{_id}.{_format}', - controller=controller, action='read_dataset', - requirements={'_format': 'xml|rdf|n3|ttl|jsonld'}) - - if p.toolkit.asbool(config.get(utils.ENABLE_CONTENT_NEGOTIATION_CONFIG)): - - _map.connect('home', '/', controller=controller, - action='read_catalog') - - _map.connect('add dataset', '/dataset/new', controller='package', action='new') - _map.connect('dataset_read', '/dataset/{_id}', - controller=controller, action='read_dataset', - ckan_icon='sitemap') - - return _map - -class MixinDCATJSONInterface(p.SingletonPlugin): - p.implements(p.IRoutes, inherit=True) - - # IRoutes - - def after_map(self, map): - - controller = 'ckanext.dcat.controllers:DCATController' - route = config.get('ckanext.dcat.json_endpoint', '/dcat.json') - map.connect(route, controller=controller, action='dcat_json') - - return map diff --git a/ckanext/dcat/processors.py b/ckanext/dcat/processors.py index 2a93d279..e11df3c8 100644 --- a/ckanext/dcat/processors.py +++ b/ckanext/dcat/processors.py @@ -426,14 +426,6 @@ def _get_from_extra(key): config.update({DCAT_EXPOSE_SUBCATALOGS: args.subcatalogs}) - # Workaround until the core translation function defaults to the Flask one - from paste.registry import Registry - from ckan.lib.cli import MockTranslator - registry = Registry() - registry.prepare() - from pylons import translator - registry.register(translator, MockTranslator()) - if args.mode == 'produce': serializer = RDFSerializer(profiles=args.profile, compatibility_mode=args.compat_mode)