Added a way to get sessiondata without creating it.
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 30 Dec 2011 01:43:55 +0000 (02:43 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 30 Dec 2011 01:43:55 +0000 (02:43 +0100)
wrw/util.py

index 7a29ea8..b94564b 100644 (file)
@@ -36,12 +36,14 @@ def persession(data = None):
 
 class sessiondata(object):
     @classmethod
 
 class sessiondata(object):
     @classmethod
-    def get(cls, req):
+    def get(cls, req, create = True):
         sess = cls.sessdb().get(req)
         with sess.lock:
             try:
                 return sess[cls]
             except KeyError:
         sess = cls.sessdb().get(req)
         with sess.lock:
             try:
                 return sess[cls]
             except KeyError:
+                if not create:
+                    return None
                 ret = cls(req)
                 sess[cls] = ret
                 return ret
                 ret = cls(req)
                 sess[cls] = ret
                 return ret