Set a global variable for all mako templates using bottle? -


i'm using bottle beaker session middleware. i'd include session object in mako templates without specifying when rendering:

instead of this:

return mako_template("myview", {      "session" : bottle.request.environ.get('beaker.session')  }) 

just this:

return mako_template("myview") 

is possible? if so, how?

i don't know mako templates, bottle simpletemplates can use basetemplate.default:

bottle.basetemplate.defaults['session'] = bottle.request.environ.get('beaker.session') 

however, since setting @ application instantiation time, bottle.request may not valid. may need turn lazy evaluation when value requested.

perhaps basetemplate.defaults gets fed mako templates, or maybe mako provides similar mechanism setting defaults?

i hope helps point in right direction.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -