Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

global: check for extension initialization in "register_menu" #65

Open
slint opened this issue Oct 25, 2018 · 0 comments
Open

global: check for extension initialization in "register_menu" #65

slint opened this issue Oct 25, 2018 · 0 comments

Comments

@slint
Copy link
Member

slint commented Oct 25, 2018

There are scenarios where some flask extension might want to provide Flask-Menu capabilities for its blueprints, but the user of the extension is not interested in this (e.g. if the application doesn't have any UI views, but only provides a REST API).

It should be possible to conditionally register the menu item, by checking if current_menu exists before performing the registration:

# inside register_menu
...
@before_first_request
def _register_menu_item():
    if current_menu:
        item = current_menu.submenu(str(path))
        item.register(...)
return f
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant