diff --git a/ckanext/xloader/plugin.py b/ckanext/xloader/plugin.py index 41e6f58e..982ff01c 100644 --- a/ckanext/xloader/plugin.py +++ b/ckanext/xloader/plugin.py @@ -116,7 +116,7 @@ def notify(self, entity, operation): # extension will call resource_patch and this method should # be called again. However, url_changed will not be in the entity # once Validation does the patch. - if 'validation' in toolkit.config.get('ckan.plugins', []) and \ + if _is_validation_plugin_loaded() and \ toolkit.asbool(toolkit.config.get('ckanext.xloader.requires_validation')): if entity.__dict__.get('extras', {}).get('validation_status', None) != 'success': log.debug("Skipping xloading resource %s because " @@ -139,7 +139,7 @@ def notify(self, entity, operation): # IResourceController def after_resource_create(self, context, resource_dict): - if 'validation' in toolkit.config.get('ckan.plugins', []) and \ + if _is_validation_plugin_loaded() and \ toolkit.asbool(toolkit.config.get('ckanext.xloader.requires_validation')) and \ resource_dict.get('validation_status', None) != 'success': log.debug("Skipping xloading resource %s because " @@ -246,3 +246,11 @@ def get_helpers(self): "xloader_status": xloader_helpers.xloader_status, "xloader_status_description": xloader_helpers.xloader_status_description, } + + +def _is_validation_plugin_loaded(): + try: + toolkit.get_action('resource_validation_show') + except KeyError: + return False + return True