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


Python SecureCookie.load_cookie方法代码示例

本文整理汇总了Python中werkzeug.contrib.securecookie.SecureCookie.load_cookie方法的典型用法代码示例。如果您正苦于以下问题:Python SecureCookie.load_cookie方法的具体用法?Python SecureCookie.load_cookie怎么用?Python SecureCookie.load_cookie使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.contrib.securecookie.SecureCookie的用法示例。


在下文中一共展示了SecureCookie.load_cookie方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_cookie

# 需要导入模块: from werkzeug.contrib.securecookie import SecureCookie [as 别名]
# 或者: from werkzeug.contrib.securecookie.SecureCookie import load_cookie [as 别名]
def load_cookie(cls, request, key="session", secret_key=None):
        """Loads a :class:`SecureCookie` from a cookie in request.  If the
        cookie is not set, a new :class:`SecureCookie` instanced is
        returned.

        :param request: a request object that has a `cookies` attribute
                        which is a dict of all cookie values.
        :param key: the name of the cookie.
        :param secret_key: the secret key used to unquote the cookie.
                           Always provide the value even though it has
                           no default!
        """
        data = request.cookies.get(key)
        if not data:
            return cls(secret_key=secret_key)
        return cls.unserialize(data, secret_key) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:18,代码来源:securecookie.py

示例2: load_cookie

# 需要导入模块: from werkzeug.contrib.securecookie import SecureCookie [as 别名]
# 或者: from werkzeug.contrib.securecookie.SecureCookie import load_cookie [as 别名]
def load_cookie(cls, request, key='session', secret_key=None):
        """Loads a :class:`SecureCookie` from a cookie in request.  If the
        cookie is not set, a new :class:`SecureCookie` instanced is
        returned.

        :param request: a request object that has a `cookies` attribute
                        which is a dict of all cookie values.
        :param key: the name of the cookie.
        :param secret_key: the secret key used to unquote the cookie.
                           Always provide the value even though it has
                           no default!
        """
        data = request.cookies.get(key)
        if not data:
            return cls(secret_key=secret_key)
        return cls.unserialize(data, secret_key) 
开发者ID:jpush,项目名称:jbox,代码行数:18,代码来源:securecookie.py

示例3: open_session

# 需要导入模块: from werkzeug.contrib.securecookie import SecureCookie [as 别名]
# 或者: from werkzeug.contrib.securecookie.SecureCookie import load_cookie [as 别名]
def open_session(self, request):
        """Creates or opens a new session.
        Default implementation stores all session data in a signed cookie.
        This requires that the :attr:`secret_key` is set.

        :param request: an instance of :attr:`request_class`.
        """
        key = self.secret_key
        if key is not None:
            return SecureCookie.load_cookie(request, self.session_cookie_name,
                                            secret_key=key)

    #
    # 关键接口: 更新session
    # 
开发者ID:hhstore,项目名称:annotated-py-projects,代码行数:17,代码来源:flask.py

示例4: test_wrapper_support

# 需要导入模块: from werkzeug.contrib.securecookie import SecureCookie [as 别名]
# 或者: from werkzeug.contrib.securecookie.SecureCookie import load_cookie [as 别名]
def test_wrapper_support(self):
        req = Request.from_values()
        resp = Response()
        c = SecureCookie.load_cookie(req, secret_key=b'foo')
        assert c.new
        c['foo'] = 42
        self.assert_equal(c.secret_key, b'foo')
        c.save_cookie(resp)

        req = Request.from_values(headers={
            'Cookie':  'session="%s"' % parse_cookie(resp.headers['set-cookie'])['session']
        })
        c2 = SecureCookie.load_cookie(req, secret_key=b'foo')
        assert not c2.new
        self.assert_equal(c2, c) 
开发者ID:GeekTrainer,项目名称:Flask,代码行数:17,代码来源:securecookie.py


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