On Feb 1, 2011, at 11:54 AM, Francisco Costa wrote:
> 
> the problem is when i open a second tab, it copies the session.id and
> doesn't recognize the new page_id
> 
> basically what i want is a diferrent session.id[page_id] for each tab
> i open

where is page_id coming from? Perhaps the intended code is:

session.id = session.id or {}
session.id['page_id'] = session.id.get('page_id', str(request.now))

But yes, the problem with this is that you'll always get the same page id 
within a session.

I see a couple more problems as well. You don't actually see "pages" or "tabs"; 
you just see requests. So a reload of a page is indistinguishable from opening 
the same page in a new tab.

Also, you have no way of knowing when a page is closed. So if you keep a dict 
of open pages in your session, it'll grow indefinitely, which could result in a 
rather large session file.

What are you really trying to do?

> 
> On Feb 1, 5:19 pm, Massimo Di Pierro <[email protected]>
> wrote:
>> session.id = session.id or {}
>> session.id[page_id]=session.id.get(page_id,str(request.now))
>> 
>> On Feb 1, 9:59 am, Francisco Costa <[email protected]> wrote:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>>> I want something like this:
>> 
>>>     if not session.id[page_id]:
>>>         session.id[page_id]=str(request.now)
>> 
>>> but i get this error: KeyError: '74'
>> 
>>> I want to validate if a dynamic variable exists.. if not I want to
>>> create it and to get the time
>> 
>>> On Feb 1, 4:17 am, Jason Brower <[email protected]> wrote:
>> 
>>>> You can do that. At the top of the default.py or what ever you are using, 
>>>> place something like...
>>>> session.pages[request.page]  = True
>>>> or how ever you want to do it. Just make sure because it is a dictionary 
>>>> that you blank it or initialize it befor asigning anything to it.
>> 
>>>> ----- Original message -----
>>>>> Hello,
>>>>> I want to have dinamic session variables like this:
>>>>>          session.id
>>>>> where id is different from page to page..
>> 
>>>>> I've tried
>>>>>          id = variable
>>>>>          session.id
>> 
>>>>> and
>>>>>          session.id['variable']
>> 
>>>>> without any results.
>> 
>>>>> I would like to be able to open different pages at the same time and
>>>>> the browser could get all the session variables.- Hide quoted text -
>> 
>>> - Show quoted text -


Reply via email to