X-Git-Url: http://dolda2000.com/gitweb/?a=blobdiff_plain;f=wrw%2Fsession.py;h=0a17c6d602120098f1fa35057fa4ba0bce131bdf;hb=920b69c320cb0dc83eec0c8b4397c7a5b80b7d5b;hp=273775be6a9888b1cec7b7a62335a1125053f670;hpb=afd93253fc4503eefe6ab5fea320a5f0dfc6e0e6;p=wrw.git diff --git a/wrw/session.py b/wrw/session.py index 273775b..0a17c6d 100644 --- a/wrw/session.py +++ b/wrw/session.py @@ -1,5 +1,5 @@ import threading, time, pickle, random, os -import cookie, env +from . import cookie, env __all__ = ["db", "get"] @@ -11,7 +11,7 @@ def hexencode(str): def gennonce(length): nonce = "" - for i in xrange(length): + for i in range(length): nonce += chr(random.randint(0, 255)) return nonce @@ -86,7 +86,7 @@ class db(object): def clean(self): now = int(time.time()) with self.lock: - clist = self.live.keys() + clist = list(self.live.keys()) for sessid in clist: with self.lock: try: @@ -168,7 +168,9 @@ class db(object): return session(threading.RLock()) def mkcookie(self, req, sess): - cookie.add(req, self.cookiename, sess.id, path=self.path) + cookie.add(req, self.cookiename, sess.id, + path=self.path, + expires=cookie.cdate(time.time() + sess.expire)) def fetch(self, req): now = int(time.time()) @@ -202,7 +204,7 @@ class db(object): data = self.backdb[sessid] try: return pickle.loads(data) - except Exception, e: + except: raise KeyError() def freeze(self, sess):