You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using two-step invocation, there is no guarantee of an app context available when session.init_app() is run. The call to db.create_all() results in an error like:
RuntimeError: application not registered on db instance and no application bound to current context
Furthermore, I don't think it's the job of Flask-Session to call this method anyway. If the table needs to be created, IMO that needs to be handled by the application developer.
Suggestions:
Just remove the call to db.create_all(); or
Add a configuration option that would allow us to skip this method being called.
If you decide on option 2 above, then IMO the call to db.create_all() should still be replaced by code that only creates the session table. Based on these docs:
The use of
self.db.create_all()
inSqlAlchemySessionInterface
is causing me some problems:https://github.com/fengsp/flask-session/blob/master/flask_session/sessions.py#L458
When using two-step invocation, there is no guarantee of an app context available when session.init_app() is run. The call to
db.create_all()
results in an error like:Furthermore, I don't think it's the job of Flask-Session to call this method anyway. If the table needs to be created, IMO that needs to be handled by the application developer.
Suggestions:
db.create_all()
; orIf you decide on option 2 above, then IMO the call to
db.create_all()
should still be replaced by code that only creates the session table. Based on these docs:http://docs.sqlalchemy.org/en/latest/core/metadata.html
That would look something like the following for
SqlAlchemySessionInterface.__init__()
:I'd be happy to create a PR if you are interested.
The text was updated successfully, but these errors were encountered: