Choosing a layout in pyramid_layout

36 views
Skip to first unread message

Mike Orr

unread,
Dec 10, 2016, 10:30:27 PM12/10/16
to pylons-...@googlegroups.com
How do you use multiple layouts with pyramid_layout? The docs show
attaching a layout to a view, but is that all it does? That doesn't
seem to provide much more than inheriting a site template, except that
you get a Python object to go with it. I would expect the power would
come in having multiple layouts for a view and allowing the siteadmin
or user to choose one at runtime. Is anyone doing something like that,
or how are you using the package? It looks like you could make them
dynamic by calling 'request.layout_manager.set_layout(name)' in the
view and storing the current layout name in a session variable.

Is there a way to get the available layout names? Otherwise the view
would have to know externally what the layout choices are.

--
Mike Orr <slugg...@gmail.com>

Mike Orr

unread,
Dec 10, 2016, 11:01:45 PM12/10/16
to pylons-...@googlegroups.com
Also, is the Mako usage really as inefficient as it looks?

<%inherit file="${context['main_template'].uri}"/>

It looks like it already has the main template object, converts it to
a URI, and then Mako has to look it up agan to get the same template
object it already has. Is this an incompatibility between
pyramid_layout and Mako that requires this kludge? Does it suggest
they don't really go together?

Randall Leeds

unread,
Dec 11, 2016, 1:11:35 AM12/11/16
to pylons-...@googlegroups.com
One also attaches panels to layouts and invokes those by name.

In other words, while I only played around with pyramid_layout briefly, what I saw as the main feature was the association of a template with a panel name + layout in much the same way that traversal allows associating a view (and renderer/template) with a view name + context. In a sense it provides a way to construct layouts out of modular sub-views bound to sub-contexts.

--
You received this message because you are subscribed to the Google Groups "pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pylons-discus...@googlegroups.com.
To post to this group, send email to pylons-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/pylons-discuss/CAH9f%3Dupj24j%3D%3D-ZdGCtCsGfSy988wmBEC4OSdMZ60xBLg-LWeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Blaise Laflamme

unread,
Dec 11, 2016, 2:36:48 PM12/11/16
to pylons-discuss
it seems that mako can't inherit from an object so you have to pass a file uri and then it has to load the template while jinja2 and chameleon can extends or use the object. Or there is a better way to inherit or extends in mako? But you're right it feels a bit odd to do this while the object is already there.
Reply all
Reply to author
Forward
0 new messages