Designing a Plugin System
Here is a little research that I did on finding how others did a plugin system.
This article - Designing a JavaScript Plugin System goes through and explains a simple plugin architecture that could be used in any system -- JavaScript, Python, or whatever.
Plugins are a common feature of libraries and frameworks, and for a good reason: they allow developers to add functionality, in a safe, scalable way. This makes the core project more valuable, and it builds a community — all without creating an additional maintenance burden. What a great deal!
So how do you go about building a plugin system? Let’s answer that question by building one of our own, in JavaScript.
It goes through a couple of examples (simplest, but has some dangers) and a slightly more complex one that limits what a plugin can do.
As an aside, while looking at this, I decided to see how jrnl implemented it's plugin system. Here is what I found:
- only for import/export of a entry/journal
- used the
__init__.pyin the plugin directory to supply the entry points to the plugin system and what gets included - only specific entries get included -- i.e. you have to manually include them, which seems reasonable
It seems to go along with what was stated in the article above.
Here are some other good resources:
- Implementing a Plugin Architecture in a Python Application
- Implementing a simple plugin framework in Python
- Yapsy: Yet Another Plugin SYstem
- Simple Plugin Methodology in Python - a PDF with source code and a decent rationale for the whys - older though.
- A Simple Plugin Framework nice discussion -- Plugin Framework - it's also old, but it goes through and has a really good discussion on what a plugin framework should do.