Chris
--
Christopher Nelson, Software Engineering Manager
SIXNET - Solutions for Your Industrial Networking Challenges
331 Ushers Road, Ballston Lake, NY 12019
Tel: +1.518.877.5173, Fax: +1.518.877.8346 www.sixnet.com
Am 20.02.2012 22:46, wrote Chris Nelson:
> 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?
Seen that in a couple if occasions, i.e. ScreenshotsPlugin implementing
the DefaultTagProvider interface [1], if TagsPlugin is installed. No
conditional import, you'll just miss the whole tracscreenshots.tags
after import failure on plugin load time. Likewise the TracAnnouncer aka
AnnouncerPlugin [2] implementing IAccountChangeListener from
AccountManagerPlugin.
I'm sure, that the try..except ImportError is done a lot more, but
ironically I can't remember an example right-away.
Steffen Hoffmann
(hasienda)
[1]
http://trac-hacks.org/browser/screenshotsplugin/0.12/tracscreenshots/tags.py
[2]
http://trac-hacks.org/browser/announcerplugin/trunk/announcer/opt/acct_mgr/announce.py
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk9CxzIACgkQ31DJeiZFuHdvFACgvVWJBMMHcPDGOsBc6uaSaczF
SPIAn3GkouFW7ibQt6En4ENC/1eRCs6V
=okTk
-----END PGP SIGNATURE-----
That's pretty code. I like that. But I'm not sure how to use it. What
I'm trying to do is extend Estimation Tools to use TracPM when installed
so I can, for example, do:
[[WorkloadChart(root=self)]]
in a ticket description and have ET defer to TracPM (my project
management shim) to figure out what "root=self" means (expand it to the
list of IDs of all descendant tickets). Following your example, I think
I need to:
* Make PM an extra in setup.py
* Add pmutil.py or something (which imports TracPM) to ET
* In utils.py, call a PM wrapper function from pmutil.py when appropriate:
if options.get('root'):
ids = pmutil.expandRoot(options)
I might go so far as
if options.get('root'):
try:
ids = pmutil.expandRoot(options)
except:
raise TracError('PM support not installed')
Since you own ET, I guess you opinion matters. ;-)