inveniosoftware / flask-breadcrumbs

Flask-Breadcrumbs is a Flask extension that adds support for generating site breadcrumb navigation.
https://flask-breadcrumbs.readthedocs.io
Other
30 stars 23 forks source link

AttributeError: 'Breadcrumbs' object has no attribute 'root_node' #57

Open miiichael opened 1 year ago

miiichael commented 1 year ago

Package version (if known): 0.5.1

Describe the bug

I'm wondering if something has changed within Flask-Menu that Flask-Breadcrumbs needs to take into account.

Steps to Reproduce

  1. Install latest releases of Flask-Breadcrumbs and Flask-Menu (0.5.1 and 1.0.0 respectively)
  2. Run the Simple Example
  3. Visit the app
  4. Profit...er, error.

Expected behavior

TypeError: The view function for 'index' did not return a valid response. The function either returned None or ended without a return statement. Ideally there would be no error, but I think index() not returning anything is a (different) bug in the example code.

Screenshots (if applicable)

Additional context

Downgrading flask-menu from 1.0.0 to 0.7.2 makes the problem go away. This leads me to believe current Flask-Breadcrumbs is incompatible with current Flask-Menu.

Lukas0907 commented 1 year ago

It seems to still work with 1.0.0 if we initializes flask-menu ourselves:

from flask_breadcrumbs import Breadcrumbs
from flask_menu import Menu

menu = Menu()
breadcrumbs = Breadcrumbs(init_menu=False)

menu.init_app(app)
breadcrumbs.init_app(app)

This is probably caused by the breadcrumbs constructor not calling super() so that the root_node attribute is not set:

https://github.com/inveniosoftware/flask-menu/blob/master/flask_menu/ext.py#L24