The two built in Session Storage objects are DiskStore and DBStore, however
web.py makes it easy to use a custom session store.  Writing a Memcache
backed session store class is very straight forward.  If you want to keep
your sessions in memory I would highly recommend this approach.


On Thu, Apr 19, 2012 at 11:45 AM, NSC <[email protected]>wrote:

> I recently had a similar question, and I'm not sure "memory" sessions are
> possible.  Unless someone corrects me, I do not believe web.py Sessions
> have a "memory" option, like Apache or IIS.  You have to tell the Session
> storage object to either use disk or db, where the storage pickle evidently
> gets written.
>
> But, I'm testing a workaround, that's not specifically a web.py thing,
> just python.
>
> In my main startup routine, I import a global.py file, which simply has a
> couple of vars defined.  Then, *before* app.run(), I'm setting those
> values.  (things like a debug level, etc).  Thanks to the magic of python
> imports, any other code file that imports that module can access those
> variables.
>
> Requests to web.py are ephemeral, but the main process runs until you kill
> it.  So, essentially I'm sticking stuff in the main process, and accessing
> it from the request threads.


> Unless I'm completely retarded, it seems to be working.
>
>
>
>
> On Thursday, April 19, 2012 3:21:46 AM UTC-4, Beau wrote:
>>
>>
>> I'm surprised no one has attempted to do anything similar ever
>> Surely you'd want to be caching non permanent data in a session
>> somehow. Isn't that half the point of sessions?
>> On Apr 2, 2:02 pm, Beau <[email protected]> wrote:
>> > Howdy.
>> >
>> > Been playing around with web.py and mimerender to create a simple site
>> > that translates other connections into RESTful urls (with json/html/
>> > xml responses).
>> >
>> > Some of this URLs currently open a TCP connection, and close it upon
>> > completion. This works fine, however it's probably not the best going
>> > forward. What I would like to do is cache the connection object for a
>> > 'session'. So if the user continually polls my service for data, it's
>> > not creating a new connection, getting the data and then closing it.
>> > I'd rather it lookup the connection and use an existing one.
>> >
>> > I've thought about using sessions, then using a dictionary for the
>> > sessionid to contain the object info etc. This could work, but I would
>> > like to close the connection if the session expires.
>> >
>> > Is there a method/interface that gets called when a session expires?.
>> > So I don't leave open TCP connections around the place.
>> >
>> > Is it possible to store the session info in memory only?. The session
>> > information does not need to be persistent, or even last longer than
>> > one minute (perfectly acceptable to open a new connection if the
>> > requests are one minute apart, but some may be 100ms apart). So
>> > writing to the disk seems odd :S.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "web.py" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/webpy/-/lCwqGm8P4_EJ.
>
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/webpy?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/webpy?hl=en.

Reply via email to