Provide usable SimplePlugin structure #15

Closed
opened 6 years ago by novirium · 1 comments
Owner

With the addition of decorators for plugin functions and hooks, a lot of the messiness required in the __init__ function for a plugin isn't necessary any more. For people who prefer their plugins to be more explicit, they can still directly subclass from plugin.Plugin, but an example SimplePlugin could be provided that does the init boilerplate (pulling in config and interface to object attributes) and provides a setup() (for other init stuff) and run() (called as a new thread for a plugin to keep running in). This would keep new custom plugins fairly clean and simple to set up. Having the critical parts only available through plugin object attributes makes them a bit hidden/magic, so just need to be sure to document them properly.

To expand on this, could potentially also provide a decorator to both turn the method into a plugin function and schedule it as a job.

With the addition of decorators for plugin functions and hooks, a lot of the messiness required in the `__init__` function for a plugin isn't necessary any more. For people who prefer their plugins to be more explicit, they can still directly subclass from plugin.Plugin, but an example SimplePlugin could be provided that does the init boilerplate (pulling in config and interface to object attributes) and provides a `setup()` (for other init stuff) and `run()` (called as a new thread for a plugin to keep running in). This would keep new custom plugins fairly clean and simple to set up. Having the critical parts only available through plugin object attributes makes them a bit hidden/magic, so just need to be sure to document them properly. To expand on this, could potentially also provide a decorator to both turn the method into a plugin function and schedule it as a job.
novirium added this to the v0.3 milestone 6 years ago
novirium added the [status] Available [type] Enhancement labels 6 years ago
Poster
Owner

This has instead been implemented by the new plugin system allowing normal functions in a module to be registered to a plugin interface (You can create a plugin without messing with classes at all)

This has instead been implemented by the new plugin system allowing normal functions in a module to be registered to a plugin interface (You can create a plugin without messing with classes at all)
novirium closed this issue 5 years ago
novirium added [status] Done and removed [status] Available labels 5 years ago
Sign in to join this conversation.
Loading…
There is no content yet.