本文整理汇总了Python中webob.Response.unset_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python Response.unset_cookie方法的具体用法?Python Response.unset_cookie怎么用?Python Response.unset_cookie使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类webob.Response
的用法示例。
在下文中一共展示了Response.unset_cookie方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_unset_cookie_key_in_cookies
# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import unset_cookie [as 别名]
def test_unset_cookie_key_in_cookies():
res = Response()
res.headers.add('Set-Cookie', 'a=2; Path=/')
res.headers.add('Set-Cookie', 'b=3; Path=/')
res.unset_cookie('a')
eq_(res.headers.getall('Set-Cookie'), ['b=3; Path=/'])
示例2: HTTPResponse
# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import unset_cookie [as 别名]
class HTTPResponse(object):
"""
Wrap WebOb's Response class.
"""
body = property(lambda self: self._res.body)
text = property(lambda self: self._res.text)
content_type = property(lambda self: self._res.content_type)
status = property(lambda self: self._res.status)
charset = property(lambda self: self._res.charset)
headerlist = property(lambda self: self._res.headerlist)
def __init__(self, body='', status=200, content_type='text/html',
charset='UTF-8', headerlist=None):
"""
body -- str or bytes that specifies the body. Empty str by default.
status -- int that specifies the status code. 200 by default.
content_type -- str that specifies the content_type. 'text/html' by default.
charset -- str that specifies the charset. 'UTF-8' by default.
headerlist -- list of tuples that specifies the header values. None by default.
"""
self._res = Response(body, status, headerlist, content_type=content_type,
charset=charset)
def cache_expires(self, seconds):
"""
Set the response to expire in the specified seconds.
seconds -- int that specifies the time for the response to expire in seconds.
"""
self._res.cache_expires(seconds)
def set_cookie(self, key, value='', max_age=None, path='/', domain=None, secure=False,
httponly=False, comment=None, overwrite=False):
"""
Set cookie.
key -- str that specifies the cookie name.
value -- str that specifies the cookie value. None unsets cookie. Empty str by default.
max_age -- int that specifies the 'Max-Age' attribute in seconds. None sets a session
cookie. None by default.
path -- str that specifies the 'Path' attribute. '/' by default.
domain -- str that specifies the 'Domain' attribute. None does not set 'Domain'
attribute. None by default.
secure -- bool that specifies wheter it is a secure cookie. If it is True, 'secure'
flag is set. If it is False, 'secure' flag is not set. False by default.
httponly -- bool that specifies wheter it is an http only cookie. If it is True,
'HttpOnly' flag is set. If it is False, 'HttpOnly' flag is not set. False
by default.
comment -- str that specifies the 'Comment' attribute. None does not set 'Comment'
attribute. None by default.
overwrite -- bool that specifies if any existing cookie with the same key should be
unset before setting this cookie. False by default.
"""
self._res.set_cookie(key, value, max_age, path, domain, secure, httponly, comment,
overwrite=overwrite)
def unset_cookie(self, key):
"""
Unset cookie with the specified key.
key -- str that specifies the cookie name.
"""
self._res.unset_cookie(key, False)
def delete_cookie(self, key, path='/', domain=None):
"""
Set cookie value to an empty str and 'Max-Age' to 0.
key -- str that specifies the cookie name.
path -- str that specifies the 'Path' attribute. '/' by default.
domain -- str that specifies the 'Domain' attribute. None by default.
"""
self._res.delete_cookie(key, path, domain)
def __call__(self, environ, start_response):
"""
WSGI application interface.
environ and start_response -- objects provided by the WSGI server.
"""
return self._res(environ, start_response)
示例3: test_unset_cookie_not_existing_and_not_strict
# 需要导入模块: from webob import Response [as 别名]
# 或者: from webob.Response import unset_cookie [as 别名]
def test_unset_cookie_not_existing_and_not_strict():
res = Response()
result = res.unset_cookie('a', strict=False)
assert result is None