From: Ben Darnell Date: Mon, 10 May 2010 01:46:06 +0000 (-0700) Subject: Support additional keyword arguments on cookies (to be handled by the X-Git-Tag: v1.0.0~44 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26af9e40e012dc6005a59921e6f066f352707733;p=thirdparty%2Ftornado.git Support additional keyword arguments on cookies (to be handled by the underlying stdlib Cookie module) --- diff --git a/tornado/web.py b/tornado/web.py index 62d135a1b..e51948a22 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -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."""