-
Notifications
You must be signed in to change notification settings - Fork 45
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
before_first_request removed as of Flask 2.3 #84
Comments
See
|
For what it's worth, this is actually super easy to fix. In init.py, change this:
to this:
And this:
to this:
Then in classy.py, do the same:
And presto! No more deprecation warnings, and compatibility with Flask 2.3. The "func" thing is in there because record_once expects to pass a function to the function it's calling, so you get an error if it's not included. |
I think that a cleaner way to do that would be to avoid the
|
I've tried both of these approaches, and for each of them I seem to be getting "Working outside of application context" errors at A compromise between the two approaches that seems to work better than either alone (at least for me) is to change:
to:
and changing However, even with this change, I still need to move my app.register_blueprint() calls to a |
I've tried to investigate this further. I have what may be a naive approach that appears to work (at least for me on a development server), but it's extraordinarily ugly. One complication I ran into is that blueprints that register menu items may be imported either before or after The attached patch attempts to deal with that by deferring the I resorted to global variables to store the list of functions to be deferred to Any recommendations on how to improve this by eliminating the |
A slightly cleaner version of the same patch:
I don't use Flask-Classy, so this patch doesn't cover required changes to |
Not sure if anyone's still paying attention to this, but I'm still looking at improved ways to address this. One thing I tripped over while looking at the code is the fact that it assumes that the endpoints for a blueprint are associated with the blueprint name, which is not necessarily correct if the blueprint is registered with a
This was always the case, but fixing this bug may be an opportunity to address this unrelated deficiency, which can be addressed by getting the endpoint when the blueprint is registered rather than directly from the The attached patch takes an approach closer to my first patch, with separate Note that if a blueprint is registered multiple times, e.g.,
then the menu items will be registered multiple times, and the URLs for the menu paths will depend on the order the blueprints are registered. It might be helpful to add functionality to There may be more elegant ways to code this patch, and I still have made no attempt to deal with |
Unfortunately, I'm new to github and don't use it for development, and am also new to Flask development. The changes to
I think my patch can be simplified further by:
I've attached a patch that incorporates that simplification and can be applied to This could perhaps be improved further by having |
Is this to be fixed or is this a dead project? |
I still don't really know my way around github development, but I've cloned the repo and created a branch with my patch as requested by utnapischtim (nearly a year ago). It applies the changes to decorators.py I attached in my previous comment and removes the Flask<2.3.0 dependency in setup.cfg. I haven't created a pull request, as I have no idea how backward-compatible the changes are. |
This project is DEAD for sure. |
flask_menu
is now broken as of Flask 2.3.0 (pallets/flask#4605):Causes: inveniosoftware/flask-breadcrumbs#56.
The text was updated successfully, but these errors were encountered: