From 7b391e6be9c3fd66be236b1cf02e8c1f8083507b Mon Sep 17 00:00:00 2001 From: pdelboca Date: Tue, 28 Feb 2023 09:28:11 -0300 Subject: [PATCH] Re introduce plugin.py file --- .../harvest/{plugin/__init__.py => plugin.py} | 26 +++++++++++++------ ckanext/harvest/plugin/flask_plugin.py | 20 -------------- 2 files changed, 18 insertions(+), 28 deletions(-) rename ckanext/harvest/{plugin/__init__.py => plugin.py} (96%) delete mode 100644 ckanext/harvest/plugin/flask_plugin.py diff --git a/ckanext/harvest/plugin/__init__.py b/ckanext/harvest/plugin.py similarity index 96% rename from ckanext/harvest/plugin/__init__.py rename to ckanext/harvest/plugin.py index 0843f7a..b4bf344 100644 --- a/ckanext/harvest/plugin/__init__.py +++ b/ckanext/harvest/plugin.py @@ -16,6 +16,7 @@ from ckan.lib.plugins import DefaultDatasetForm from ckan.lib.plugins import DefaultTranslation import ckanext.harvest +from ckanext.harvest import cli, views from ckanext.harvest.model import setup as model_setup from ckanext.harvest.model import HarvestSource, HarvestJob, HarvestObject from ckanext.harvest.log import DBLogHandler @@ -24,14 +25,13 @@ from ckanext.harvest.utils import ( DATASET_TYPE_NAME ) -from ckanext.harvest.plugin.flask_plugin import MixinPlugin - log = getLogger(__name__) assert not log.disabled -class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): - +class Harvest(p.SingletonPlugin, DefaultDatasetForm, DefaultTranslation): + p.implements(p.IClick) + p.implements(p.IBlueprint) p.implements(p.IConfigurable) p.implements(p.IConfigurer, inherit=True) p.implements(p.IActions) @@ -44,6 +44,16 @@ class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTransla startup = False + # IClick + + def get_commands(self): + return cli.get_commands() + + # IBlueprint + + def get_blueprint(self): + return views.get_blueprints() + # ITranslation def i18n_directory(self): u'''Change the directory of the .mo translation files''' @@ -266,10 +276,10 @@ class Harvest(MixinPlugin, p.SingletonPlugin, DefaultDatasetForm, DefaultTransla self.startup = False def update_config(self, config): - p.toolkit.add_template_directory(config, '../templates') - p.toolkit.add_public_directory(config, '../public') - p.toolkit.add_resource('../fanstatic_library', 'ckanext-harvest') - p.toolkit.add_resource('../public/ckanext/harvest/javascript', 'harvest-extra-field') + p.toolkit.add_template_directory(config, 'templates') + p.toolkit.add_public_directory(config, 'public') + p.toolkit.add_resource('fanstatic_library', 'ckanext-harvest') + p.toolkit.add_resource('public/ckanext/harvest/javascript', 'harvest-extra-field') if p.toolkit.check_ckan_version(min_version='2.9.0'): mappings = config.get('ckan.legacy_route_mappings') or {} diff --git a/ckanext/harvest/plugin/flask_plugin.py b/ckanext/harvest/plugin/flask_plugin.py deleted file mode 100644 index 7b8208a..0000000 --- a/ckanext/harvest/plugin/flask_plugin.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- - -import ckan.plugins as p -import ckanext.harvest.cli as cli -import ckanext.harvest.views as views - - -class MixinPlugin(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 views.get_blueprints()