substanced icon indicating copy to clipboard operation
substanced copied to clipboard

Binding the master page macro to IBeforeRender.

Open Themanwithoutaplan opened this issue 8 years ago • 1 comments

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.

Themanwithoutaplan avatar Mar 19 '16 13:03 Themanwithoutaplan

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

Themanwithoutaplan avatar Mar 19 '16 14:03 Themanwithoutaplan