pallets-eco / flask-debugtoolbar

A toolbar overlay for debugging Flask applications
https://flask-debugtoolbar.readthedocs.io
BSD 3-Clause "New" or "Revised" License
953 stars 146 forks source link

More example details #53

Closed rogerbinns closed 9 years ago

rogerbinns commented 11 years ago

Not mentioned in the example shown are two things. One is why you save to a toolbar variable that is never used. (Presumably this is to prevent garbage collection in which case a comment to that effect would be helpful.)

The second is that the template being rendered requires a <head> section. The simplest template shown in http://flask.pocoo.org/docs/quickstart/ (search for "Here is an example template") omits html/head/body and as a result the toolbar doesn't show up.

mgood commented 9 years ago

Sorry for this extremely late response.

It's not strictly necessary to store the toolbar in a variable, since it will register itself with Flask's hooks which will prevent it from being garbage collected. Storing it is useful if you want to call toolbar.init_app(app), but not required otherwise. However, this is a common pattern for how extensions are initialized so I've just left it there for consistency.

With #20 merged, it will now emit a warning when the </body> tag is not present, and the toolbar isn't inserted. There is another issue #79 still open for addressing that in a better way, so I'll close this out in favor of that.