]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Support additional keyword arguments on cookies (to be handled by the
authorBen Darnell <bdarnell@beaker.local>
Mon, 10 May 2010 01:46:06 +0000 (18:46 -0700)
committerBen Darnell <bdarnell@beaker.local>
Mon, 10 May 2010 01:46:06 +0000 (18:46 -0700)
underlying stdlib Cookie module)

tornado/web.py

index 62d135a1b98d20f7d36fd598b2488c8531c0e11b..e51948a2217d0042f58e6a5b6c0e56c08fc3b438 100644 (file)
@@ -215,8 +215,14 @@ class RequestHandler(object):
         return default
 
     def set_cookie(self, name, value, domain=None, expires=None, path="/",
-                   expires_days=None):
-        """Sets the given cookie name/value with the given options."""
+                   expires_days=None, **kwargs):
+        """Sets the given cookie name/value with the given options.
+
+        Additional keyword arguments are set on the Cookie.Morsel
+        directly.
+        See http://docs.python.org/library/cookie.html#morsel-objects
+        for available attributes.
+        """
         name = _utf8(name)
         value = _utf8(value)
         if re.search(r"[\x00-\x20]", name + value):
@@ -238,6 +244,8 @@ class RequestHandler(object):
                 timestamp, localtime=False, usegmt=True)
         if path:
             new_cookie[name]["path"] = path
+        for k, v in kwargs.iteritems():
+            new_cookie[name][k] = v
 
     def clear_cookie(self, name, path="/", domain=None):
         """Deletes the cookie with the given name."""