Refactor plugin - #607
Conversation
|
Cool! Thanks for getting the ball rolling. FWIW, this bit of refactoring—gathering up the loading logic and some other stuff into a PluginRegistry class—seems reasonable to merge sooner rather than later. It doesn't cause any API breakage—right? [Side note: I'm going to be slow on responding to this and your other recent changes, @geigerzaehler, for a a few days due to RL obligations. Sorry for my negligence! I'll try to get to everything before long.] |
|
I wrote a few more design notes on a new wiki page. |
|
Just came across instructions to extend the |
|
Yes, good point—that was of dubious utility anyway (I can't even recall the original excuse for adding it). Let's dispose of that functionality. |
|
I added some thoughts on singleton to the wiki. |
|
That's a good point, @geigerzaehler — it would be easier to manage the instance lifetime externally. |
Backported from #607. See #607 (comment) This will be return in #644.
|
After giving it some thought, I’ve come to the conclusion that it’s best to move away from the namespace approach to plugins. Instead a plugin should just be a python module name
Of course we should retain the core plugins in |
|
Yep, seems right to me. I'm still divided on whether |
|
I just tried to write code for the new naming convention that keeps backwards compatibility with beetsplug: It’s hard 😓! And I don't think it's worth it—we should just rely on the new mechanism. Also in favor of |
|
True; it does seem hard! We might need to make a clean break, which would be fine. |
See beetbox#607 (comment) (rebased-with-history from commit eca58cf)
Only the plugin registry must instantiate plugins, and it does not use the name arguemnt.
None of the plugins does use this to set a name.
2ded210 to
4b11eed
Compare
|
This seems like it would be better served as a WIP reference to someone else that would like to continue it on a new PR |
|
Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward? This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
In this PR we try to develop a new plugin API. The API has two parts: the
BeetsPluginclass to be used by plugins and the functions beets uses to interact with plugins. See also the wiki.At the moment the only change is the addition of a
Registryclass to encapsulate all interactions with plugins.TODO
BeetsPluginmethods to expose event handlers. If I understood @sampsyo in Exception handling for item writes #603 correctly this means that a plugin simply needs to implement aon_writemethod to register a 'write' event handler.plugins.registryor migrate all code to the new registry API.Make subclasses ofObsoleteBeetsPluginsingeltons by overwriting the__new__function.