Easy context hooks for plugins
|Reported by:||Christopher Allan Webber||Owned by:|
|Cc:||Will Kahn-Greene, Elrond||Parent Tickets:|
We now have template hook support. But maybe you want to add things to the context!
We'd like to make this fairly easy. One way to do it is probably make it so you can lazily attach plugins to the context, even without making an extra call.
This might work like so:
- Extend the MediaGoblinApp to attach request.view_name onto the request, which is the path to the view (maybe even its "logical name" used to look up that view name in the routing, or just the pythonpath to that view)
- Whenever render_to_response is called, it checks to see if there's a hook for that view name and template, like so: PluginApi.get_hook_callables("some.view.name-mediagoblin/something/template.html-context") (yes, this is overly-verbose, one other option is to start namespacing hooks and use a tuple of (view_name, template_name) as the key)
- Iterate through each of those functions passing in the context so plugins can mess with the context dict.