[ckan-dev] check for plugins

Harald von Waldow harald.vonwaldow at eawag.ch
Wed Feb 22 16:43:03 UTC 2017


I would like to have a template-helper that tells me whether a certain plugin is loaded. This here works, but I'd be glad for any hints to achieve this less convoluted and more elegantly and future-proof:


import ckan.plugins as p

def eaw_check_plugin(pluginname):
    ifaces = (eval('p.{}'.format(name)) for name in p.interfaces.__all__)
    implemented = [item.name
                   for iface in ifaces
                   for item in p.PluginImplementations(iface)]
    return pluginname in implemented


Thanks,
Harald

-- 
Harald von Waldow
Eawag
ICT Services
Ueberlandstrasse 133
8600 Duebendorf
http://www.eawag.ch

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20170222/f5371d97/attachment-0002.sig>


More information about the ckan-dev mailing list