Hey guys, I'm working on extending an already existing webapp written in tornado using flask. Things are going great so far, and eventually i'll rewrite the original system as well. However for now I need a way to use the Tornado session manager in flask. Any suggestions? Thanks, Sidhant
On Tue, Oct 5, 2010 at 9:21 AM, Sidhant Godiwala < sidhant.godiwala@infinitelybeta.com> wrote: > Things are going great so far, and eventually i'll rewrite the original > system as well. However for now I need a way to use the Tornado session > manager in flask. > Is there any particular feature in Tornado session manager that Flask can't reproduce? -- Jonas
Its really the encrypted cookie, I need access to. I need to use the 2 functions get_secure_cookie and set_secure_cookie in the RequestHandler http://github.com/facebook/tornado/blob/master/tornado/web.py I'd rather use Tornado as a dependency and was looking for a clean way to do this. Sidhant On Tue, 2010-10-05 at 10:10 -0300, Jonas Galvez wrote: > > On Tue, Oct 5, 2010 at 9:21 AM, Sidhant Godiwala > <sidhant.godiwala@infinitelybeta.com> wrote: > Things are going great so far, and eventually i'll rewrite the > original > system as well. However for now I need a way to use the > Tornado session > manager in flask. > > > Is there any particular feature in Tornado session manager that Flask > can't reproduce? > > > -- Jonas > >
On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala < sidhant.godiwala@infinitelybeta.com> wrote: > Its really the encrypted cookie, I need access to. > > I need to use the 2 functions get_secure_cookie and set_secure_cookie in > the RequestHandler > http://github.com/facebook/tornado/blob/master/tornado/web.py > > I'd rather use Tornado as a dependency and was looking for a clean way > to do this. From a quick glance at that source code, I would guess these functions are too tightly coupled into the framework and you won't be able to use them separately with clean imports (without any sort of patching). Try isolating their behavior and reproducing them in your Flask code. -- Jonas
After a bit of refactoring, everythings working fine :) Thanks a lot Sidhant On Tue, 2010-10-05 at 11:04 -0300, Jonas Galvez wrote: > On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala > <sidhant.godiwala@infinitelybeta.com> wrote: > Its really the encrypted cookie, I need access to. > > I need to use the 2 functions get_secure_cookie and > set_secure_cookie in > the RequestHandler > http://github.com/facebook/tornado/blob/master/tornado/web.py > > I'd rather use Tornado as a dependency and was looking for a > clean way > to do this. > > > From a quick glance at that source code, I would guess these functions > are too tightly coupled into the framework and you won't be able to > use them separately with clean imports (without any sort of patching). > Try isolating their behavior and reproducing them in your Flask code. > > > -- Jonas
Hi could you please share as to how you went about doing it. Alice On Wed, Oct 6, 2010 at 5:16 PM, Sidhant Godiwala < sidhant.godiwala@infinitelybeta.com> wrote: > After a bit of refactoring, everythings working fine :) > > Thanks a lot > Sidhant > > On Tue, 2010-10-05 at 11:04 -0300, Jonas Galvez wrote: > > On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala > > <sidhant.godiwala@infinitelybeta.com> wrote: > > Its really the encrypted cookie, I need access to. > > > > I need to use the 2 functions get_secure_cookie and > > set_secure_cookie in > > the RequestHandler > > http://github.com/facebook/tornado/blob/master/tornado/web.py > > > > I'd rather use Tornado as a dependency and was looking for a > > clean way > > to do this. > > > > > > From a quick glance at that source code, I would guess these functions > > are too tightly coupled into the framework and you won't be able to > > use them separately with clean imports (without any sort of patching). > > Try isolating their behavior and reproducing them in your Flask code. > > > > > > -- Jonas > > >
Sure,
I refactored the function out (only decryption), you can have a look
here http://gist.github.com/616440
you can access the cookie using the flask.request object
s = app.config["cookie_secret"]
@app.route("/")
def index():
return _decrypt_cookie("encrypted", request.cookies["encrypted"], s)
Sidhant
On Thu, 2010-10-07 at 21:56 +0530, alice ni wrote:
> Hi could you please share as to how you went about doing it.
> Alice
>
> On Wed, Oct 6, 2010 at 5:16 PM, Sidhant Godiwala
> <sidhant.godiwala@infinitelybeta.com> wrote:
> After a bit of refactoring, everythings working fine :)
>
> Thanks a lot
> Sidhant
>
>
> On Tue, 2010-10-05 at 11:04 -0300, Jonas Galvez wrote:
> > On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala
> > <sidhant.godiwala@infinitelybeta.com> wrote:
> > Its really the encrypted cookie, I need access to.
> >
> > I need to use the 2 functions get_secure_cookie and
> > set_secure_cookie in
> > the RequestHandler
> >
> http://github.com/facebook/tornado/blob/master/tornado/web.py
> >
> > I'd rather use Tornado as a dependency and was
> looking for a
> > clean way
> > to do this.
> >
> >
> > From a quick glance at that source code, I would guess these
> functions
> > are too tightly coupled into the framework and you won't be
> able to
> > use them separately with clean imports (without any sort of
> patching).
> > Try isolating their behavior and reproducing them in your
> Flask code.
> >
> >
> > -- Jonas
>
>
>
>
>
Why didn't use werkzeug secure cookie? http://werkzeug.pocoo.org/documentation/dev/contrib/securecookie.html 2010/10/8 Sidhant Godiwala <sidhant.godiwala@infinitelybeta.com> > Sure, > > I refactored the function out (only decryption), you can have a look > here http://gist.github.com/616440 > > you can access the cookie using the flask.request object > > s = app.config["cookie_secret"] > > @app.route("/") > def index(): > return _decrypt_cookie("encrypted", request.cookies["encrypted"], s) > > Sidhant > > On Thu, 2010-10-07 at 21:56 +0530, alice ni wrote: > > Hi could you please share as to how you went about doing it. > > Alice > > > > On Wed, Oct 6, 2010 at 5:16 PM, Sidhant Godiwala > > <sidhant.godiwala@infinitelybeta.com> wrote: > > After a bit of refactoring, everythings working fine :) > > > > Thanks a lot > > Sidhant > > > > > > On Tue, 2010-10-05 at 11:04 -0300, Jonas Galvez wrote: > > > On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala > > > <sidhant.godiwala@infinitelybeta.com> wrote: > > > Its really the encrypted cookie, I need access to. > > > > > > I need to use the 2 functions get_secure_cookie and > > > set_secure_cookie in > > > the RequestHandler > > > > > http://github.com/facebook/tornado/blob/master/tornado/web.py > > > > > > I'd rather use Tornado as a dependency and was > > looking for a > > > clean way > > > to do this. > > > > > > > > > From a quick glance at that source code, I would guess these > > functions > > > are too tightly coupled into the framework and you won't be > > able to > > > use them separately with clean imports (without any sort of > > patching). > > > Try isolating their behavior and reproducing them in your > > Flask code. > > > > > > > > > -- Jonas > > > > > > > > > > > > > -- Rodrigo Aliste P.
Hey, I would have, but I had to integrate with a system already using tornado and setting a tornado secret cookie Sidhant On Fri, 2010-10-08 at 10:27 -0400, Rodrigo Aliste P. wrote: > Why didn't use werkzeug secure cookie? > > > http://werkzeug.pocoo.org/documentation/dev/contrib/securecookie.html > > 2010/10/8 Sidhant Godiwala <sidhant.godiwala@infinitelybeta.com> > Sure, > > I refactored the function out (only decryption), you can have > a look > here http://gist.github.com/616440 > > you can access the cookie using the flask.request object > > s = app.config["cookie_secret"] > > @app.route("/") > def index(): > return _decrypt_cookie("encrypted", > request.cookies["encrypted"], s) > > Sidhant > > > On Thu, 2010-10-07 at 21:56 +0530, alice ni wrote: > > Hi could you please share as to how you went about doing it. > > Alice > > > > On Wed, Oct 6, 2010 at 5:16 PM, Sidhant Godiwala > > <sidhant.godiwala@infinitelybeta.com> wrote: > > After a bit of refactoring, everythings working > fine :) > > > > Thanks a lot > > Sidhant > > > > > > On Tue, 2010-10-05 at 11:04 -0300, Jonas Galvez > wrote: > > > On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala > > > <sidhant.godiwala@infinitelybeta.com> wrote: > > > Its really the encrypted cookie, I need > access to. > > > > > > I need to use the 2 functions > get_secure_cookie and > > > set_secure_cookie in > > > the RequestHandler > > > > > > http://github.com/facebook/tornado/blob/master/tornado/web.py > > > > > > I'd rather use Tornado as a dependency and > was > > looking for a > > > clean way > > > to do this. > > > > > > > > > From a quick glance at that source code, I would > guess these > > functions > > > are too tightly coupled into the framework and you > won't be > > able to > > > use them separately with clean imports (without > any sort of > > patching). > > > Try isolating their behavior and reproducing them > in your > > Flask code. > > > > > > > > > -- Jonas > > > > > > > > > > > > > > > > > -- > Rodrigo Aliste P. > >
Aha! So you just wanted to read the cookie from Flask, cool :) 2010/10/8 Sidhant Godiwala <sidhant.godiwala@infinitelybeta.com> > Hey, > > I would have, but I had to integrate with a system already using tornado > and setting a tornado secret cookie > > Sidhant > > On Fri, 2010-10-08 at 10:27 -0400, Rodrigo Aliste P. wrote: > > Why didn't use werkzeug secure cookie? > > > > > > http://werkzeug.pocoo.org/documentation/dev/contrib/securecookie.html > > > > 2010/10/8 Sidhant Godiwala <sidhant.godiwala@infinitelybeta.com> > > Sure, > > > > I refactored the function out (only decryption), you can have > > a look > > here http://gist.github.com/616440 > > > > you can access the cookie using the flask.request object > > > > s = app.config["cookie_secret"] > > > > @app.route("/") > > def index(): > > return _decrypt_cookie("encrypted", > > request.cookies["encrypted"], s) > > > > Sidhant > > > > > > On Thu, 2010-10-07 at 21:56 +0530, alice ni wrote: > > > Hi could you please share as to how you went about doing it. > > > Alice > > > > > > On Wed, Oct 6, 2010 at 5:16 PM, Sidhant Godiwala > > > <sidhant.godiwala@infinitelybeta.com> wrote: > > > After a bit of refactoring, everythings working > > fine :) > > > > > > Thanks a lot > > > Sidhant > > > > > > > > > On Tue, 2010-10-05 at 11:04 -0300, Jonas Galvez > > wrote: > > > > On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala > > > > <sidhant.godiwala@infinitelybeta.com> wrote: > > > > Its really the encrypted cookie, I need > > access to. > > > > > > > > I need to use the 2 functions > > get_secure_cookie and > > > > set_secure_cookie in > > > > the RequestHandler > > > > > > > > > http://github.com/facebook/tornado/blob/master/tornado/web.py > > > > > > > > I'd rather use Tornado as a dependency and > > was > > > looking for a > > > > clean way > > > > to do this. > > > > > > > > > > > > From a quick glance at that source code, I would > > guess these > > > functions > > > > are too tightly coupled into the framework and you > > won't be > > > able to > > > > use them separately with clean imports (without > > any sort of > > > patching). > > > > Try isolating their behavior and reproducing them > > in your > > > Flask code. > > > > > > > > > > > > -- Jonas > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > Rodrigo Aliste P. > > > > > > > -- Rodrigo Aliste P.
Hey, I would have, but I had to integrate with a system already using tornado and setting a tornado secret cookie Sidhant On Fri, 2010-10-08 at 10:27 -0400, Rodrigo Aliste P. wrote: > Why didn't use werkzeug secure cookie? > > > http://werkzeug.pocoo.org/documentation/dev/contrib/securecookie.html > > 2010/10/8 Sidhant Godiwala <sidhant.godiwala@infinitelybeta.com> > Sure, > > I refactored the function out (only decryption), you can have > a look > here http://gist.github.com/616440 > > you can access the cookie using the flask.request object > > s = app.config["cookie_secret"] > > @app.route("/") > def index(): > return _decrypt_cookie("encrypted", > request.cookies["encrypted"], s) > > Sidhant > > > On Thu, 2010-10-07 at 21:56 +0530, alice ni wrote: > > Hi could you please share as to how you went about doing it. > > Alice > > > > On Wed, Oct 6, 2010 at 5:16 PM, Sidhant Godiwala > > <sidhant.godiwala@infinitelybeta.com> wrote: > > After a bit of refactoring, everythings working > fine :) > > > > Thanks a lot > > Sidhant > > > > > > On Tue, 2010-10-05 at 11:04 -0300, Jonas Galvez > wrote: > > > On Tue, Oct 5, 2010 at 10:22 AM, Sidhant Godiwala > > > <sidhant.godiwala@infinitelybeta.com> wrote: > > > Its really the encrypted cookie, I need > access to. > > > > > > I need to use the 2 functions > get_secure_cookie and > > > set_secure_cookie in > > > the RequestHandler > > > > > > http://github.com/facebook/tornado/blob/master/tornado/web.py > > > > > > I'd rather use Tornado as a dependency and > was > > looking for a > > > clean way > > > to do this. > > > > > > > > > From a quick glance at that source code, I would > guess these > > functions > > > are too tightly coupled into the framework and you > won't be > > able to > > > use them separately with clean imports (without > any sort of > > patching). > > > Try isolating their behavior and reproducing them > in your > > Flask code. > > > > > > > > > -- Jonas > > > > > > > > > > > > > > > > > -- > Rodrigo Aliste P. > >