On Feb 20, 10:46 pm, Chris Nelson <[email protected]> wrote:
> Can someone point me to an example of where one plugin *may* make use of
> another plugin?  That is, I want one plugin to use another if it is
> present but not to *require* it.  It this just putting the `import` in a
> `try` or is there a better idiom?
>
>                                                  Chris

See for instance setup.py for my FullBlogPlugin that optionally will
support tagsplugin and spamfilterplugin if present. Notice the [tags]
and [spamfilter] markers in entry_points + extras_require conditions.
The conditional entry points will only be declared when extras match:

http://trac-hacks.org/browser/fullblogplugin/0.11/setup.py

You obviously need to structure your code so that the particular
extras code are not loaded when not needed. Like in the example from
my plugin that means that when the entry_point condition isn't
matched, there is nothing else trying to import that particular file.
For my 'tracfullblog/tags.py' for example that means I can just
'import tractags' without having to write try-except handling as
nothing should attempt to load the file unless the dependency is
available.


:::simon

https://www.coderesort.com
http://trac-hacks.org/wiki/osimons

-- 
You received this message because you are subscribed to the Google Groups "Trac 
Development" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/trac-dev?hl=en.

Reply via email to