4

I like mako and wish it were easier to integrate with the Flask framework. I setup the flask-mako extension but quickly discovered that instead of the very nice flask debugger screen producing an easily understood traceback like it did with jinja, I get an almost useless version with little descriptions and inaccurate line numbers (I'd provide some hard evidence, but I have already uninstalled).

This thread describes a way to setup mako with better exception handling, which I assume was my problem, but from what I can tell, it looks like I would need to run a try/except on every one of my url functions?

Isn't there a way to turn this exception handling "always on" so the flask debugger will be usable without all this extra effort?

Several places mention how easy it is to swap jinja/mako in flask, but I am finding that is not the case. Hopefully I'm missing something...

Community
  • 1
  • 1
chrickso
  • 2,994
  • 5
  • 30
  • 53

1 Answers1

0

flask-mako is a very simple package. Instead of wrapping every one of your render calls with try: except:, I suggest that you instead fork flask-mako, and in flaskext/mako.py wrap the render call (line 53 on the current master) with the mako try except. A quick pass at doing so can be found at: https://github.com/jd-boyd/flask-mako

However, while that makes the error in the mako template much easier to find, it still does not let you use the flask debugger to debug mako templates.

Joshua D. Boyd
  • 4,808
  • 3
  • 29
  • 44