Merge branch 'master' into python3
[wrw.git] / wrw / session.py
index d78c43b..02d1983 100644 (file)
@@ -1,5 +1,5 @@
 import threading, time, pickle, random, os
-from . import cookie
+from . import cookie, env
 
 __all__ = ["db", "get"]
 
@@ -19,7 +19,7 @@ class session(object):
     def __init__(self, expire = 86400 * 7):
         self.id = hexencode(gennonce(16))
         self.dict = {}
-        self.lock = threading.Lock()
+        self.lock = threading.RLock()
         self.ctime = self.atime = self.mtime = int(time.time())
         self.expire = expire
         self.dctl = set()
@@ -180,7 +180,7 @@ class dirback(object):
         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):
-    return default.get(req)
+    return default.val.get(req)