当前位置: 首页>>代码示例>>Python>>正文


Python Response.unset_cookie方法代码示例

本文整理汇总了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=/'])
开发者ID:GdZ,项目名称:scriptfile,代码行数:8,代码来源:test_response.py

示例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)
开发者ID:ral99,项目名称:weppy,代码行数:84,代码来源:http.py

示例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
开发者ID:GdZ,项目名称:scriptfile,代码行数:6,代码来源:test_response.py


注:本文中的webob.Response.unset_cookie方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。