I add a MemStore to store the session in the memory that's good.
_memsession_ = {}
class MemStore(Store):
def __contains__(self, key):
return _memsession_.has_key(key)
def __getitem__(self, key):
if _memsession_.has_key(key):
return _memsession_.get(key)[0]
raise KeyError, key
def __setitem__(self, key, value):
_memsession_[key] = (value, time.time())
def __delitem__(self, key):
if _memsession_.has_key(key):
del _memsession_[key]
def cleanup(self, timeout):
now = time.time()
for k,(v,atime) in _memsession_.items():
if now - atime > timeout :
del _memsession_[k]
Insert the above code in the proper position of session.py, enjoy it.
2009-11-02
shwdai
发件人: Leon Waldman
发送时间: 2009-10-31 23:20:45
收件人: webpy
抄送:
主题: [webpy] Re: appengine datastore and sessions
Hi,
You want to store the sessions on the DB?
Why?
(Anothes thing, it would be better te store they on the memcache cluster).
On Fri, Oct 30, 2009 at 9:23 PM, Matt Silbernagel <[email protected]> wrote:
Has anyone tried and/or been successful using appengines datastore
with web.py's sessions?
--
--
Leon Waldman
SysAdmin Linux - Arquiteto de Infra-Estrutura & TI.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---