librelist archives

« back to archive

sessions

sessions

From:
Mihai Sandu
Date:
2012-06-07 @ 12:11
I have some problems with a flask program.
I have an API in python who query elasticsearch and a flask program with a
web interface who use the API.
And in the web interface I'm setting some filters and sending to the API.
How to make it to have different settings (filters) for different
sessions(users/computers) ?
Thanks.

Re: [flask] sessions

From:
Simon Sapin
Date:
2012-06-07 @ 13:13
Le 07/06/2012 14:11, Mihai Sandu a écrit :
> I have some problems with a flask program.
> I have an API in python who query elasticsearch and a flask program with
> a web interface who use the API.
> And in the web interface I'm setting some filters and sending to the API.
> How to make it to have different settings (filters) for different
> sessions(users/computers) ?

I’m really not sure what you mean, but you can use flask.session as a 
dict and it will be available across requests for a given user (through 
a signed cookie)

http://flask.pocoo.org/docs/quickstart/#sessions
http://flask.pocoo.org/docs/api/#sessions

-- 
Simon Sapin

Re: [flask] sessions

From:
Mihai Sandu
Date:
2012-06-07 @ 16:33
Ok, let me explain more. From the web interface (flask) I get a filter, let
say "result limit" who limit the result from the elasticsearch.
And then I access the API with this "result limit" filter, and API give me
the results with that limit.
The problem is if a user A login to the interface and put a "result limit"
of 10, and in the same time another user B want to search for something it
will search with the "result limit" filter 10. And I want that these user
to be independent one from another.

On Thu, Jun 7, 2012 at 4:13 PM, Simon Sapin <simon.sapin@exyr.org> wrote:

> Le 07/06/2012 14:11, Mihai Sandu a écrit :
> > I have some problems with a flask program.
> > I have an API in python who query elasticsearch and a flask program with
> > a web interface who use the API.
> > And in the web interface I'm setting some filters and sending to the API.
> > How to make it to have different settings (filters) for different
> > sessions(users/computers) ?
>
> I’m really not sure what you mean, but you can use flask.session as a
> dict and it will be available across requests for a given user (through
> a signed cookie)
>
> http://flask.pocoo.org/docs/quickstart/#sessions
> http://flask.pocoo.org/docs/api/#sessions
>
> --
> Simon Sapin
>
>
>

Re: [flask] sessions

From:
pronoyc@gmail.com
Date:
2012-06-07 @ 16:42
> Ok, let me explain more. From the web interface (flask) I get a filter,
> let say "result limit" who limit the result from the elasticsearch.
> And then I access the API with this "result limit" filter, and API give me
> the results with that limit.
> The problem is if a user A login to the interface and put a "result limit"
> of 10, and in the same time another user B want to search for something it
> will search with the "result limit" filter 10. And I want that these user
> to be independent one from another.
>

Sorry, but why wouldn't it be independent? User A and User B are not
sharing the same session. If that were the case, if User A logged in then
any other user wouldn't have to login ever again.

-- 
Regards,

Pronoy Chopra
http://blog.pronoy.in <http://www.pronoy.in/about>/
http://www.twitter.com/pronoyc

Re: [flask] sessions

From:
Mihai Sandu
Date:
2012-06-07 @ 17:03
I dont know what I did wrong. But forget about users, let say I connect
with the same user but from different computers and aren't independent.

On Thu, Jun 7, 2012 at 7:42 PM, pronoyc@gmail.com <pronoyc@gmail.com> wrote:

>
> Ok, let me explain more. From the web interface (flask) I get a filter,
>> let say "result limit" who limit the result from the elasticsearch.
>> And then I access the API with this "result limit" filter, and API give
>> me the results with that limit.
>> The problem is if a user A login to the interface and put a "result
>> limit" of 10, and in the same time another user B want to search for
>> something it will search with the "result limit" filter 10. And I want that
>> these user to be independent one from another.
>>
>
> Sorry, but why wouldn't it be independent? User A and User B are not
> sharing the same session. If that were the case, if User A logged in then
> any other user wouldn't have to login ever again.
>
> --
> Regards,
>
> Pronoy Chopra
> http://blog.pronoy.in <http://www.pronoy.in/about>/
> http://www.twitter.com/pronoyc
>
>

Re: [flask] sessions

From:
Simon Sapin
Date:
2012-06-07 @ 17:21
Le 07/06/2012 19:03, Mihai Sandu a écrit :
> I dont know what I did wrong. But forget about users, let say I connect
> with the same user but from different computers and aren't independent.

Are you using global variables on the server side?

If the queries you send are only based on the parameters to your view 
function, the 'request' and the 'session' object, there should be no 
problem.

-- 
Simon Sapin

Re: [flask] sessions

From:
pronoyc@gmail.com
Date:
2012-06-07 @ 17:24
It will still be a different session. Independent. Don't worry about that.
Session ends when a user logs out. Say if User A logs in from two different
computers to the same website, a different session will be started.

I dont know what I did wrong. But forget about users, let say I connect
> with the same user but from different computers and aren't independent.



-- 
Regards,

Pronoy Chopra
http://blog.pronoy.in <http://www.pronoy.in/about>/
http://www.twitter.com/pronoyc

Re: [flask] sessions

From:
Mihai Sandu
Date:
2012-06-08 @ 06:38
I have something like this:

if 'limits' in request.form.values():
                limits_checked = "checked"
                limits_selected = request.form['limits2']
                try:
                    limits_int = int(limits_selected)
                    api.queryLimit(limits_int)
                except:
                    text_final = "'Result limits' must be a number!"
                    return render_template(main_,
username=escape(session['username']), text=text_final)

On Thu, Jun 7, 2012 at 8:24 PM, pronoyc@gmail.com <pronoyc@gmail.com> wrote:

> It will still be a different session. Independent. Don't worry about that.
> Session ends when a user logs out. Say if User A logs in from two different
> computers to the same website, a different session will be started.
>
>
> I dont know what I did wrong. But forget about users, let say I connect
>> with the same user but from different computers and aren't independent.
>
>
>
> --
> Regards,
>
> Pronoy Chopra
> http://blog.pronoy.in <http://www.pronoy.in/about>/
> http://www.twitter.com/pronoyc
>
>

Re: [flask] sessions

From:
Mihai Sandu
Date:
2012-06-11 @ 08:04
Is something wrong in my code?

On Fri, Jun 8, 2012 at 9:38 AM, Mihai Sandu <voyagersm@gmail.com> wrote:

> I have something like this:
>
> if 'limits' in request.form.values():
>                 limits_checked = "checked"
>                 limits_selected = request.form['limits2']
>                 try:
>                     limits_int = int(limits_selected)
>                     api.queryLimit(limits_int)
>                 except:
>                     text_final = "'Result limits' must be a number!"
>                     return render_template(main_,
> username=escape(session['username']), text=text_final)
>
> On Thu, Jun 7, 2012 at 8:24 PM, pronoyc@gmail.com <pronoyc@gmail.com>wrote:
>
>> It will still be a different session. Independent. Don't worry about
>> that. Session ends when a user logs out. Say if User A logs in from two
>> different computers to the same website, a different session will be
>> started.
>>
>>
>> I dont know what I did wrong. But forget about users, let say I connect
>>> with the same user but from different computers and aren't independent.
>>
>>
>>
>> --
>> Regards,
>>
>> Pronoy Chopra
>> http://blog.pronoy.in <http://www.pronoy.in/about>/
>> http://www.twitter.com/pronoyc
>>
>>
>