flask-breadcrumbs icon indicating copy to clipboard operation
flask-breadcrumbs copied to clipboard

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

Open miiichael opened this issue 2 years ago • 1 comments

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.

miiichael avatar Sep 09 '23 14:09 miiichael

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

Lukas0907 avatar Sep 26 '23 16:09 Lukas0907