Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions ckanext/datastore_refresh/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import ckan.plugins.toolkit as tk
import click

from ckan.common import config


log = logging.getLogger(__name__)

Expand Down Expand Up @@ -67,12 +69,20 @@ def _submit_resource(dataset, resource, context):
"""resource: resource dictionary"""
# Copied and modifed from ckan/default/src/ckanext-xloader/ckanext/xloader/cli.py to check for Xloader formats before submitting
# import here, so that that loggers are setup
from ckanext.xloader.plugin import XLoaderFormats

if not XLoaderFormats.is_it_an_xloader_format(resource["format"]):
try:
from ckanext.xloader.plugin import XLoaderFormats

can_subbmit = XLoaderFormats.is_it_an_xloader_format(resource["format"])
except ImportError:
can_subbmit = resource["format"] and resource[
"format"
].lower() in config.get("ckan.datapusher.formats")

if not can_subbmit:
click.echo(
f'Skipping resource {resource["id"]} because format'
f' "{resource["format"]}" is not configured to be xloadered'
f' "{resource["format"]}" is not configured to be loadered'
)
return
if resource["url_type"] in ("datapusher", "xloader"):
Expand Down
11 changes: 8 additions & 3 deletions ckanext/datastore_refresh/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
import ckan.plugins.toolkit as tk
from ckan.views.api import API_DEFAULT_VERSION

import ckanext.xloader.interfaces as xloader_interfaces
try:
import ckanext.xloader.interfaces as xloader_interfaces
loader_interface = xloader_interfaces.IXloader
except ImportError:
import ckanext.datapusher.interfaces as datapusher_interfaces
loader_interface = datapusher_interfaces.IDataPusher

from . import cli, helpers, view
from .logic import auth, action
Expand All @@ -22,7 +27,7 @@ class DatastoreRefreshPlugin(plugins.SingletonPlugin):
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.IClick)
plugins.implements(plugins.IBlueprint)
plugins.implements(xloader_interfaces.IXloader, inherit=True)
plugins.implements(loader_interface, inherit=True)

# ITemplateHelpers
def get_helpers(self):
Expand Down Expand Up @@ -57,7 +62,7 @@ def get_commands(self):
def get_blueprint(self):
return view.get_blueprints()

# IXLoader
# IXloader or IDataPusher depends environment
def after_upload(self, context, resource_dict, dataset_dict):
_purge_section_cache(context, resource_dict, dataset_dict)

Expand Down