This is my attempt to port the plugin-loading code from server-core over to pyramid. It makes use of zope.interface and pyramid's internal component registry, which means it has a bit of a different flavor to the old system, but I think it's worth it.
To load a plugin from a named section in the config file:
plugin = load_and_register("somesection", config)
This not only returns it, but also stores it away in the pyramid registry. Other parts of the code can find it by doing:
I think this gives us most of what's in the server-core plugin code while cooperating nicely with pyramid - in particular, it takes advantage of pyramid's conflict detection and resolution algorithms to make sure that you've configured a single implementation of each plugin interface.
(there are also "load_from_config" and "load_from_settings" functions if you dont want/need to jump through all the zopey registration hoops)
This is my attempt to port the plugin-loading code from server-core over to pyramid. It makes use of zope.interface and pyramid's internal component registry, which means it has a bit of a different flavor to the old system, but I think it's worth it.
To load a plugin from a named section in the config file:
This not only returns it, but also stores it away in the pyramid registry. Other parts of the code can find it by doing:
I think this gives us most of what's in the server-core plugin code while cooperating nicely with pyramid - in particular, it takes advantage of pyramid's conflict detection and resolution algorithms to make sure that you've configured a single implementation of each plugin interface.
(there are also "load_from_config" and "load_from_settings" functions if you dont want/need to jump through all the zopey registration hoops)
Thoughts?