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

AttributeError: 'Flask' object has no attribute 'before_first_request'. #36

Open
bezborodow opened this issue May 8, 2023 · 4 comments

Comments

@bezborodow
Copy link

It seems that flask_rbac is using deprecated API. before_first_request is no longer supported.

 Traceback (most recent call last):
   File "app/uwsgi.py", line 4, in <module>
     app = create_app()
           ^^^^^^^^^^^^
   File "/opt/www/gaas-bms/app/__init__.py", line 32, in create_app
     rbac.init_app(app)
   File "/opt/www/gaas-bms/venv/lib64/python3.11/site-packages/flask_rbac/__init__.py", line 179, in init_app
     app.before_first_request(self._setup_acl)
     ^^^^^^^^^^^^^^^^^^^^^^^^
 AttributeError: 'Flask' object has no attribute 'before_first_request'.
@marcopolomercader
Copy link

marcopolomercader commented May 22, 2023

before_first_request is deprecated since Flask 2.3.0. To solve this you need to change it for before_request in the code.

I dont think this Flask-RBAC package will be updated.

Warining that in Flask 2.4.x will remove more deprecated code that is used in this Package.

@bezborodow
Copy link
Author

To solve this you need to change it for before_request in the code.

That is incorrect. The recommendation is to move configuration code to the setup phase of the application.

See pallets/flask/issues/4605.

@bezborodow
Copy link
Author

I don't think this Flask-RBAC package will be updated.

In this case, should we mark the entire package as deprecated?

hokanosekai added a commit to hokanosekai/flask-rbac that referenced this issue Feb 7, 2024
hokanosekai added a commit to hokanosekai/flask-rbac that referenced this issue Feb 7, 2024
@jt-bg
Copy link

jt-bg commented Apr 18, 2024

I ran into this issue as well. Copying Hokanosekai's code into venv worked locally for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants