| Jim Gallacher 2005-04-09, 8:45 pm |
| dharana wrote:
>
> Nicolas Lehuen wrote:
>
>
> The session is only saved after a .save() call, like MemorySession and
> DbmSession do. If you load a session and don't .save() it, it won't have
> the _accessed field updated (If I understood correctly the code).
>
Absolutely. But the point of sessions is to save some state information
on the server across requests, isn't it? Why wouldn't you save it? If
you are not saving, why bother with sessions at all? Just put it all in
a cookie and be done with it. Or am I missing something? (I hope that
doen't sound like a rant. It really isn't. 
On the other hand, if we end up using the file mtime to track session
access there is an optimization available. Something like:
if dict._is_dirty:
cPickle.dump(sess_file,dict)
sess._is_dirty = False
else:
update_file_mtime(sess_file)
Any application code that modifies the session data would be responsible
for setting the _is_dirty flag.
This could save a whole lot of pickle dumping time on a busy site if the
session data tends not to change between requests. Of course, handling
it this way invalidates the secondary check of the session expiry I
talked about earlier.
Regards,
Jim
|