mozilla-services / mozservices

INACTIVE - http://mzl.la/ghe-archive - Various utilities for Pyramid-based Mozilla applications
33 stars 17 forks source link

Plugin loading system #2

Closed rfk closed 13 years ago

rfk commented 13 years ago

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:

plugin = request.registry.queryUtility(ISomePlugin)

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?

tarekziade commented 13 years ago

so the merge button works in chromium, but not in nightly. looks like a js bug