Re: [flask] after save session hook?
- From:
- Simon Sapin
- Date:
- 2011-12-22 @ 09:10
Le 22/12/2011 09:36, Bharadwaj Parthasarathy a écrit :
>
> I am building an app for a cookie less environment and I am using server
side sessions with URL rewriting for passing session_id.
> I am using an server side session store(Flask KVSession), which uses a
dictionary store for sessions.
> I am trying to pass session id to the template.
>
> On the first request, I am storing objects on the session. However, I am
not able to pass the session.id to the template.
> This is because the save_session call happens after most hooks. I am not
able to use @app.context_processor nor @app.after_request
> The @app.context_processor is called before the save_session.
> The @app.after_request is called after the save_session, but the
response seems to have been already built.
> Is there a way to inject data to the context after save_session and
before make_response?
>
> Thanks
Hi,
Try saving the session to a dummy response to force the ID to be
generated. Saving the same session twice will probably keep the same ID,
but I don’t know the details of KVSession.
http://flask.pocoo.org/docs/api/#flask.Flask.save_session
Regards,
--
Simon Sapin