substanced
substanced copied to clipboard
Binding the master page macro to IBeforeRender.
This is probably a matter of style but the scaffold suggests that retail views should always call the master template in order to use macros and slots. I think that in this context subscribing to the event makes more sense.
I'd add something like this to the retail.__init__.py
or a macros file.
from pyramid.renderers import get_renderer
from pyramid.interfaces import IBeforeRender
from pyramid.events import subscriber
@subscriber(IBeforeRender)
def globals_factory(event):
master = get_renderer('templates/master.pt').implementation()
event['master'] = master