[ckan-dev] check for plugins

Ian Ward ian at excess.org
Wed Feb 22 17:16:59 UTC 2017


Wherever possible I move templates that depend on a plugin into those
plugins to avoid this kind of checking. It's a trade-off between more
complicated template hierarchies vs. dependencies creeping into
unrelated extensions.

What's the larger problem you're solving that you think needs this?

On Wed, Feb 22, 2017 at 11:43 AM, Harald von Waldow
<harald.vonwaldow at eawag.ch> wrote:
> 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
>
>
> _______________________________________________
> ckan-dev mailing list
> ckan-dev at lists.okfn.org
> https://lists.okfn.org/mailman/listinfo/ckan-dev
> Unsubscribe: https://lists.okfn.org/mailman/options/ckan-dev
>



More information about the ckan-dev mailing list