Dolda2000 GitWeb
/
wrw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Handle cookie attributes more flexibly.
[wrw.git]
/
wrw
/
session.py
diff --git
a/wrw/session.py
b/wrw/session.py
index
428c93d
..
19bdb6b
100644
(file)
--- a/
wrw/session.py
+++ b/
wrw/session.py
@@
-70,6
+70,9
@@
class session(object):
self.__dict__[k] = v
# The proper lock is set by the thawer
self.__dict__[k] = v
# The proper lock is set by the thawer
+ def __repr__(self):
+ return "<session %s>" % self.id
+
class db(object):
def __init__(self, backdb = None, cookiename = "wrwsess", path = "/"):
self.live = {}
class db(object):
def __init__(self, backdb = None, cookiename = "wrwsess", path = "/"):
self.live = {}
@@
-154,15
+157,17
@@
class db(object):
else:
raise Exception("Illegal session entry: " + repr(entry[1]))
else:
raise Exception("Illegal session entry: " + repr(entry[1]))
- def fetch(self, req):
- now = int(time.time())
- sessid = cookie.get(req, self.cookiename)
- new = False
+ def checkclean(self):
with self.lock:
if self.cthread is None:
self.cthread = threading.Thread(target = self.cleanloop)
self.cthread.setDaemon(True)
self.cthread.start()
with self.lock:
if self.cthread is None:
self.cthread = threading.Thread(target = self.cleanloop)
self.cthread.setDaemon(True)
self.cthread.start()
+
+ def fetch(self, req):
+ now = int(time.time())
+ sessid = cookie.get(req, self.cookiename)
+ new = False
try:
if sessid is None:
raise KeyError()
try:
if sessid is None:
raise KeyError()
@@
-174,13
+179,14
@@
class db(object):
def ckfreeze(req):
if sess.dirty():
if new:
def ckfreeze(req):
if sess.dirty():
if new:
- cookie.add(req, self.cookiename, sess.id, self.path)
+ cookie.add(req, self.cookiename, sess.id,
path=
self.path)
with self.lock:
self.live[sess.id] = [sess.lock, sess]
try:
self.freeze(sess)
except:
pass
with self.lock:
self.live[sess.id] = [sess.lock, sess]
try:
self.freeze(sess)
except:
pass
+ self.checkclean()
req.oncommit(ckfreeze)
return sess
req.oncommit(ckfreeze)
return sess