Skip to content

Commit ef57870

Browse files
awsetMarkCalvert
authored andcommitted
[DATAVIC-559] replaced xloader wrapper with datapusher plus
1 parent 93fcdc4 commit ef57870

2 files changed

Lines changed: 10 additions & 13 deletions

File tree

ckanext/datavic_odp_theme/plugin.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from ckan import model, types
1111

1212
from ckanext.search_autocomplete.interfaces import ISearchAutocomplete
13-
from ckanext.datapusher.plugin import DatapusherPlugin
13+
from ckanext.datapusher_plus.plugin import DatapusherPlusPlugin
1414

1515
from ckanext.datavic_odp_theme.logic import auth_functions, actions, get_validators
1616
from ckanext.datavic_odp_theme.views import get_blueprints
@@ -182,7 +182,7 @@ class DatavicODPThemeAuth(p.SingletonPlugin):
182182
pass
183183

184184

185-
class DatavicDatapusherPlugin(DatapusherPlugin, p.SingletonPlugin):
185+
class DatavicDatapusherPlusPlugin(DatapusherPlusPlugin, p.SingletonPlugin):
186186
p.implements(p.IPackageController, inherit=True)
187187

188188
# IPackageController
@@ -211,11 +211,11 @@ def after_dataset_update(self, context, pkg_dict):
211211
group.add_package_by_name(pkg_dict.get('name'))
212212

213213
def _submit_new_resources_only(self, pkg_dict):
214-
"""Submit only newly added resources to xloader during dataset update.
214+
"""Submit only newly added resources to datapusher during dataset update.
215215
216216
Compares current resource IDs against the previous activity snapshot
217217
to detect new resources. URL changes for existing resources are
218-
handled by the parent xloaderPlugin via ``notify()``.
218+
handled by the parent DatapusherPlusPlugin via ``notify()``.
219219
220220
Falls back to submitting all resources if no activity data is
221221
available (e.g. activity plugin disabled, data migration).
@@ -288,7 +288,7 @@ def _infer_format_and_submit(self, resource):
288288
resource["format"] = (
289289
url_without_params.split(".")[-1].lower()
290290
)
291-
self._submit_to_xloader(resource)
291+
self._submit_to_datapusher(resource)
292292

293293
def _trigger_after_resource_create(self, pkg_dict):
294294
"""Submit all resources after dataset creation.
@@ -300,13 +300,10 @@ def _trigger_after_resource_create(self, pkg_dict):
300300
self._infer_format_and_submit(resource)
301301

302302
def _submit_to_datapusher(self, resource_dict):
303-
"""The original method doesn't check if `url_type` is here. Seems like
304-
it's not here if we are calling it from the `after_dataset_create`.
305-
Just set a default url_type and delete after to be sure, that it doesn't break
306-
some core logic.
307-
308-
Do not touch proper values, because it will definitely break something."""
309-
303+
"""Wrapper that ensures ``url_type`` and ``format`` are present
304+
before calling the parent, as they may be missing for resources
305+
created inline via ``package_create``/``package_update``.
306+
"""
310307
resource_dict.setdefault("url_type", "datavic_datapusher")
311308
resource_dict.setdefault("format", "")
312309

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
[ckan.plugins]
6464
datavic_odp_theme=ckanext.datavic_odp_theme.plugin:DatavicODPTheme
6565
datavic_odp_theme_auth=ckanext.datavic_odp_theme.plugin:DatavicODPThemeAuth
66-
datavic_odp_datapusher=ckanext.datavic_odp_theme.plugin:DatavicDatapusherPlugin
66+
datavic_odp_datapusher_plus=ckanext.datavic_odp_theme.plugin:DatavicDatapusherPlusPlugin
6767
6868
[babel.extractors]
6969
ckan = ckan.lib.extract:extract_ckan

0 commit comments

Comments
 (0)