Replies: 4 comments 2 replies
-
FS requires the provided datastore manage sessions - I.e. pushing/creating on request entry and popping/closing on request pop. I am not familiar with 'Session Maker' - but you might have to define your own DataStore (possibly similar to SQLAlchemySessionUserDatastore) |
Beta Was this translation helpful? Give feedback.
-
So are you using SQLAlchemySessionUserDatastore as your FS datastore? and can you share your configuration code? |
Beta Was this translation helpful? Give feedback.
-
yes! for sure. thanks: DB Configuration: import os SQLALCHEMY_DATABASE_URI= os.environ.get('SQLALCHEMY_DATABASE_URI') engine = create_engine(SQLALCHEMY_DATABASE_URI, pool_size=14) SessionFactory = scoped_session(sessionmaker(bind=engine)) query = SessionFactory.query_property() session = SessionFactory() Base = declarative_base() Base.query = query` FS: babel = Babel(app, default_locale='es') app.config['SECRET_KEY'] = 'super secret key' from flask_security import RegisterForm user_datastore = SQLAlchemySessionUserDatastore(session, User, Role) Flask Application Instantiation:
|
Beta Was this translation helpful? Give feedback.
-
Sorry I haven't had much time to think about this. I did try to write a unit test that exposed this same issue but so far no luck. For Flask-SQLAlchemy (SQLAlchemyUserDatastore) - it handles the session completely. Note that Flask-SQLAlchemy registers @app.teardown_appcontext(self._teardown_session) which manages the session - you might try the same thing. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I am using on my project SQL Alchemy with Session Maker. Installed Flask-Security-Too as a bootsstrap for user authentication.
But what I detected is that when I do multi-device CRUD (i.e. I have a user on my desktop). Log-in with the user on my cell an update a user date), it gives an error:
sqlalchemy.exc.InvalidRequestError: Object '<User at 0x7f8dc23c7670>' is already attached to session '10' (this is '1')
So, I think that in some way this happens because Flask Security Too doesn't follows strictly Session Guideliness (none session is close after a query). Do I have a correct diagnostic? I have the idea that adding session close woudl be a solution and I am going to go in that direction.
Beta Was this translation helpful? Give feedback.
All reactions