Is there a bottle.py equivalent of context processors that you get in Flask?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re using vanilla Bottle with SimpleTemplate, there is a solution I’ve stumbled upon.
For my site, I needed access to some functions in every template,
app.get_urlbeing obviously one of them. This worked for me:This works as of Bottle 0.9, I didn’t test on more recent versions of the framework.
This behavior is undocumented, but Marcel Hellkamp explained it in this thread. In there, other solutions are also mentioned:
_varsor a similar template arg.Also, in Bottle 0.10, new functions related to the problem were introduced in the SimpleTemplate template namespace:
defined,get, andsetdefault