Handle cookie attributes more flexibly.
authorFredrik Tolf <fredrik@dolda2000.com>
Sun, 8 Jul 2012 06:26:00 +0000 (08:26 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Sun, 8 Jul 2012 06:26:00 +0000 (08:26 +0200)
wrw/cookie.py
wrw/session.py

index 37e8708..16ddf81 100644 (file)
@@ -27,9 +27,10 @@ class cookiedict(object):
             return default
         return self.bk[name].value
 
-    def add(self, name, value, path = None):
+    def add(self, name, value, **kw):
         self.codec[name] = value
-        if path is not None: self.codec[name]["path"] = path
+        for key, value in kw.iteritems():
+            self.codec[name][key] = value
 
     def __setitem__(self, name, value):
         self.add(name, value)
@@ -40,5 +41,5 @@ def cookies(req):
 def get(req, name, default = None):
     return cookies(req).get(name, default)
 
-def add(req, name, value, path = None):
-    cookies(req).add(name, value, path)
+def add(req, name, value, **kw):
+    cookies(req).add(name, value, **kw)
index edf8f7d..19bdb6b 100644 (file)
@@ -179,7 +179,7 @@ class db(object):
         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: