From f18f76bf13468e709fd7af4b763e824f69376292 Mon Sep 17 00:00:00 2001 From: kindly Date: Thu, 24 Oct 2013 19:14:36 +0100 Subject: [PATCH] [#1200] add loaded plugin logic --- ckan/plugins/core.py | 11 ++++++++++- ckanext/datastore/logic/action.py | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ckan/plugins/core.py b/ckan/plugins/core.py index 8f3752117ea..f39c8062917 100644 --- a/ckan/plugins/core.py +++ b/ckan/plugins/core.py @@ -18,7 +18,7 @@ 'PluginNotFoundException', 'Plugin', 'SingletonPlugin', 'load', 'load_all', 'unload', 'unload_all', 'get_plugin', 'plugins_update', - 'use_plugin', + 'use_plugin', 'plugin_loaded', ] log = logging.getLogger(__name__) @@ -210,6 +210,15 @@ def unload(*plugins): plugins_update() +def plugin_loaded(name): + ''' + See if a particular plugin is loaded. + ''' + if name in _PLUGINS: + return True + return False + + def find_system_plugins(): ''' Return all plugins in the ckan.system_plugins entry point group. diff --git a/ckanext/datastore/logic/action.py b/ckanext/datastore/logic/action.py index aadf896dbe4..804fec1a197 100644 --- a/ckanext/datastore/logic/action.py +++ b/ckanext/datastore/logic/action.py @@ -96,7 +96,7 @@ def datastore_create(context, data_dict): # create resource from file if has_url: - if not 'datapusher' in pylons.config.get('ckan.plugins', ''): + if not p.plugin_loaded('datapusher'): raise p.toolkit.ValidationError({'resource': [ 'The datapusher has to be enabled.']}) p.toolkit.get_action('datapusher_submit')(context, {