當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。