agdsn / sipa

The Supreme Information Providing Application
MIT License
13 stars 10 forks source link

Stop using `_app_ctx_stack` in favor of `flask.g` #447

Closed lukasjuhrich closed 1 year ago

lukasjuhrich commented 1 year ago

We currently have the following deprecation warning:

/home/lukas/.virtualenvs/sipa/lib/python3.10/site-packages/flask_sqlalchemy/init.py:14: DeprecationWarning: '_app_ctx_stack' is deprecated and will be removed in Flask 2.3.

Note the following section in the 2.2 flask docs

An older technique for storing context data was to store it on _app_ctx_stack.top or _request_ctx_stack.top. However, this just moves the same namespace collision problem elsewhere (although less likely) and modifies objects that are very internal to Flask’s operations. Prefer storing data under a unique name in g.

lukasjuhrich commented 1 year ago

In this case however, the culprit is just the (now unused) flask_sqlalchemy package.