Added an explicit get function to session databases.
authorFredrik Tolf <fredrik@dolda2000.com>
Thu, 1 Dec 2011 20:26:54 +0000 (21:26 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Thu, 1 Dec 2011 20:26:54 +0000 (21:26 +0100)
wrw/session.py

index 9e91ad9..284d092 100644 (file)
@@ -134,7 +134,7 @@ class db(object):
         return sess
 
     def ckfreeze(self, req):
         return sess
 
     def ckfreeze(self, req):
-        sess = req.item(self.fetch)
+        sess = self.get(req)
         if sess.dirty():
             try:
                 if getattr(sess, "new", False):
         if sess.dirty():
             try:
                 if getattr(sess, "new", False):
@@ -150,6 +150,9 @@ class db(object):
     def freeze(self, sess):
         raise TypeError()
 
     def freeze(self, sess):
         raise TypeError()
 
+    def get(self, req):
+        return req.item(self.fetch)
+
 class backeddb(db):
     def __init__(self, backdb, *args, **kw):
         super(backeddb, self).__init__(*args, **kw)
 class backeddb(db):
     def __init__(self, backdb, *args, **kw):
         super(backeddb, self).__init__(*args, **kw)
@@ -186,4 +189,4 @@ class dirback(object):
 default = backeddb(dirback(os.path.join("/tmp", "wrwsess-" + str(os.getuid()))))
 
 def get(req):
 default = backeddb(dirback(os.path.join("/tmp", "wrwsess-" + str(os.getuid()))))
 
 def get(req):
-    return req.item(default.fetch)
+    return default.get(req)