sampsyo/beets — pull request #607 by geigerzaehler (2014-03-13 13:02:31+00:00)
Title: Refactor plugin

In this PR we try to develop a new plugin API. The API has two parts: the `BeetsPlugin` class to be used by plugins and the functions beets uses to interact with plugins. See also the [wiki](https://github.com/sampsyo/beets/wiki/Refactoring#wiki-plugin-api-overhaul).

At the moment the only change is the addition of a `Registry` class to encapsulate all interactions with plugins.

##### TODO

- [ ] Use `BeetsPlugin` methods to expose event handlers. If I understood @sampsyo in #603 correctly this means that a plugin simply needs to implement a `on_write` method to register a 'write' event handler.

- [ ] Think of a clever way to expose the default registry without a calling `plugins.registry` or migrate all code to the new registry API.

- [ ] Make subclasses of `BeetsPlugin` singeltons by overwriting the `__new__` function.

- [ ] Clarify the usage of namespace packages. At the moment I’m leaning towards keeping then, since they actually [work quite well](https://gist.github.com/geigerzaehler/9508410) if we are careful.

- [ ] Devise a way to migrate to the new API or provide a compatibility layer.