This is a pretty old question, but here, I think it might do the trick. Keep in mind that when you write a template, you are actually showing the body() function by default.
I assume that mainactions is defined as a local variable for self.body() . But everything is cool, since we have access to ourselves ...
so instead of writing:
mainactions = [request.route_url('clientsnew')]
You should try to write:
self.mainactions = [request.route_url('clientsnew')]
However, this is not a very good way to achieve what you wanted to do. If I were you, I would do it with def or block .
base.mako
<h1>${self.view()}</h1> <%block name="mainaction"> </%block> ${self.body()} <%def name="listactions(actions)"> <ul> % for action in actions: <li>${action}</li> % endfor </ul> </%def>
clientbase.mako
<%inherit file="base.mako"/> <%def name="view()">Clients</%def> <%block name="mainaction" ${request.route_url('clientsnew')} </%block>
The rest do not change ... the thing with def is that you simply override def from the parent, and then use def where you want in base.mako .
This is pretty much the case.
source share