flask-sqlalchemy-session icon indicating copy to clipboard operation
flask-sqlalchemy-session copied to clipboard

__ident_func__ removed from werkzeug 2.1

Open schettino72 opened this issue 4 years ago • 4 comments

Code relies on __ident_func__ that will be removed from werkzeug 2.1.

See https://github.com/pallets/werkzeug/commit/9dee4cdeef7384a0d3873fa46a65cfb9c089718b

schettino72 avatar Dec 19 '21 13:12 schettino72

Thanks

dtheodor avatar Dec 20 '21 08:12 dtheodor

I am getting an error:

AttributeError: 'LocalStack' object has no attribute 'ident_func'

Will this fix it?

npcole avatar Jun 29 '22 23:06 npcole

@npcole I get the error like this: AttributeError: '_FakeStack' object has no attribute 'ident_func'

But I fixed it by modify the code in https://github.com/dtheodor/flask-sqlalchemy-session/blob/master/flask_sqlalchemy_session/init.py

I use these version:

python 3.10
Package                  Version
------------------------ -------------
Flask                    2.2.2
Flask-SQLAlchemy         2.5.1
Flask-SQLAlchemy-Session 1.1
greenlet                 1.1.2
pip                      22.2.2
SQLAlchemy               1.4.40
Werkzeug                 2.2.2

find out lib/python3.10/site-packages/flask_sqlalchemy_session/init.py add

try:
    from greenlet import getcurrent as _ident_func
except ImportError:
    from threading import get_ident as _ident_func

update https://github.com/dtheodor/flask-sqlalchemy-session/blob/47f4480ec2de87678faede4b174eb9a08fc84725/flask_sqlalchemy_session/init.py#L53

 super(flask_scoped_session, self).__init__(
            session_factory,
            scopefunc=_ident_func)

reference in here: https://github.com/pallets-eco/flask-sqlalchemy/commit/3565f0587519168c5ea4301f6e4bfba8c2ac4dee?diff=split

wsx5031060310guy avatar Aug 26 '22 02:08 wsx5031060310guy

Can we get this fix into the latest release?

npcole avatar Jul 05 '23 17:07 npcole