On Friday, June 7, 2013 3:23:02 PM UTC-4, Anthony wrote:
>
> If the session changes during the request, it gets pickled at the end of 
> every request and stored in the session file (or db or cookie if using db 
> or cookie based sessions). At the beginning of each request, the session is 
> read from the file (or db or cookie) and unpickled. Anything that can't be 
> pickled can't be stored in the session.
>
>
Well it's not so much that I want to store something in the session itself. 
Here is my problem specifically:

We use a unix domain socket in some of our controllers to grab data via rpc 
from another process. Currently, we have to create a new socket connection 
for each request, but I would like to reuse the socket and have one socket 
per one actual person making the requests (hence session). This works just 
fine, however, I don't know when the socket is no longer necessary (ie. the 
user logs out). At this point I think my only option is to setup a timer 
that just closes the socket after a set timeout period, because there is no 
callback to tell when the session is over.


 

> Anthony
>
> On Friday, June 7, 2013 11:56:19 AM UTC-4, Matt wrote:
>>
>>
>>
>> On Friday, June 7, 2013 11:28:48 AM UTC-4, Matt wrote:
>>>
>>> On Friday, June 7, 2013 9:53:42 AM UTC-4, Anthony wrote:
>>>
>>>> current.session is just the session object, which is in the web2py 
>>>> global environment -- it contains the user's session for the current 
>>>> request. The session itself does not include its own ID. If you want the 
>>>> session ID, it is in response.session_id (also, 
>>>> current.response.session_id). For file based sessions, the filename is in 
>>>> response.session_filename.
>>>>
>>>> Also, the session cookie name is in response.session_id_name, so to get 
>>>> the session cookie, do request.cookies[response.session_id_name].
>>>>
>>>>
>>> Anthony,
>>> Thanks for the clarification. What I'm really trying to do is to persist 
>>> an object for a given session (a local unix domain socket to an rpc 
>>> interface), but there doesn't seem to be any easy way to do this. 
>>> Specifically, there doesn't seem to be a way for me to determine when a 
>>> session has been closed/deleted in order to clean up the socket. Do you 
>>> know of any way to do this? 
>>>
>>>
>> As a followup: I thought initially I could just create the object in the 
>> thread local storage for the current.session, but it seems that this is 
>> created anew for all requests and responses? 
>>  
>>
>>> Matt
>>>  
>>>
>>>> Anthony
>>>>
>>>> On Tuesday, June 4, 2013 8:35:06 AM UTC-4, Matt wrote:
>>>>>
>>>>> Hi,
>>>>> In one of my modules I'm trying to create a local socket connection 
>>>>> that persists across a single session (one socket per one user logged 
>>>>> into 
>>>>> the system from a given browser), and thought that current.session would 
>>>>> give me the info I needed. Specifically, we use a lot of REST calls in 
>>>>> our 
>>>>> frontend code to populate data for certain elements on the screen and 
>>>>> this 
>>>>> creates a new session hash for the current.session each time, but the 
>>>>> actual session is the same. The only way I've been able to get a key that 
>>>>> identifies the session is to run: 
>>>>>
>>>>>     cookies = current.request["cookies"]
>>>>>     session = cookies["session_id_<appname>"].value
>>>>>
>>>>> Shouldn't some identifier (or even this cookie itself) be available in 
>>>>> current.session? Perhaps I misunderstand the point of current.session.
>>>>>
>>>>> Matt
>>>>>
>>>>>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to