Re introduce plugin.py file

This commit is contained in:
pdelboca 2023-02-28 09:28:11 -03:00
parent a47a4f1a4f
commit 7b391e6be9
2 changed files with 18 additions and 28 deletions

View File

@ -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 {}

View File

@ -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()