Dolda2000 GitWeb
/
wrw.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into python3
[wrw.git]
/
wrw
/
session.py
diff --git
a/wrw/session.py
b/wrw/session.py
index
7632449
..
832387e
100644
(file)
--- a/
wrw/session.py
+++ b/
wrw/session.py
@@
-1,5
+1,5
@@
import threading, time, pickle, random, os
import threading, time, pickle, random, os
-import cookie
+from . import cookie, env
__all__ = ["db", "get"]
__all__ = ["db", "get"]
@@
-11,7
+11,7
@@
def hexencode(str):
def gennonce(length):
nonce = ""
def gennonce(length):
nonce = ""
- for i in
x
range(length):
+ for i in range(length):
nonce += chr(random.randint(0, 255))
return nonce
nonce += chr(random.randint(0, 255))
return nonce
@@
-84,7
+84,7
@@
class db(object):
now = int(time.time())
with self.lock:
dlist = []
now = int(time.time())
with self.lock:
dlist = []
- for sess in self.live.
iter
values():
+ for sess in self.live.values():
if sess.atime + self.freezetime < now:
try:
if sess.dirty():
if sess.atime + self.freezetime < now:
try:
if sess.dirty():
@@
-151,7
+151,7
@@
class db(object):
data = self.backdb[sessid]
try:
return pickle.loads(data)
data = self.backdb[sessid]
try:
return pickle.loads(data)
- except
Exception, e
:
+ except:
raise KeyError()
def freeze(self, sess):
raise KeyError()
def freeze(self, sess):
@@
-180,7
+180,7
@@
class dirback(object):
with open(os.path.join(self.path, key), "w") as out:
out.write(value)
with open(os.path.join(self.path, key), "w") as out:
out.write(value)
-default =
db(backdb = dirback(os.path.join("/tmp", "wrwsess-" + str(os.getuid(
)))))
+default =
env.var(db(backdb = dirback(os.path.join("/tmp", "wrwsess-" + str(os.getuid()
)))))
def get(req):
def get(req):
- return default.get(req)
+ return default.
val.
get(req)