While editing a record, if there is a long wait of let say a few minutes (getting coffee) and then coming back to press the save (POST), I get redirected to the main page to login instead and the data is lost.
It seems the flask-login session expires too fast.
I did some research and came across this.
from flask import session, app
session.permanent = True
Is this the proper way to go? But even when I try this I get this exception:
File "/Users/kave/workspace/F11A/src/application/__init__.py", line 14, in <module>
session.permanent = True
File "/Users/kave/workspace/F11A/src/lib/werkzeug/local.py", line 355, in <lambda>
__setattr__ = lambda x, n, v: setattr(x._get_current_object(), n, v)
File "/Users/kave/workspace/F11A/src/lib/werkzeug/local.py", line 297, in _get_current_object
return self.__local()
File "/Users/kave/workspace/F11A/src/lib/flask/globals.py", line 20, in _lookup_req_object
raise RuntimeError('working outside of request context')
RuntimeError: working outside of request context
If you try to access the session object like this it won't work.
As the error message says,
flask.session
can only be used from within a request context, which won't exist at that point. You should only use it from within a route.Just in case someone else will have this question. I suppose Hooman already got answer.
Won`t work
views.py
Will work
session
must be used inside the request.