當前位置: 首頁>>代碼示例>>Python>>正文


Python Client.build_wsgi_environ方法代碼示例

本文整理匯總了Python中aspen.testing.client.Client.build_wsgi_environ方法的典型用法代碼示例。如果您正苦於以下問題:Python Client.build_wsgi_environ方法的具體用法?Python Client.build_wsgi_environ怎麽用?Python Client.build_wsgi_environ使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在aspen.testing.client.Client的用法示例。


在下文中一共展示了Client.build_wsgi_environ方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_wsgi_environ

# 需要導入模塊: from aspen.testing.client import Client [as 別名]
# 或者: from aspen.testing.client.Client import build_wsgi_environ [as 別名]
    def build_wsgi_environ(self, *a, **kw):
        """Extend base class to support authenticating as a certain user.
        """

        # csrf - for both anon and authenticated
        self.cookie[b'csrf_token'] = b'sotokeny'
        kw[b'HTTP_X-CSRF-TOKEN'] = b'sotokeny'

        # user authentication
        auth_as = kw.pop('auth_as', None)
        if auth_as is None:
            if SESSION in self.cookie:
                del self.cookie[SESSION]
        else:
            user = User.from_username(auth_as)
            user.sign_in(self.cookie)

        return Client.build_wsgi_environ(self, *a, **kw)
開發者ID:atunit,項目名稱:www.gittip.com,代碼行數:20,代碼來源:__init__.py

示例2: build_wsgi_environ

# 需要導入模塊: from aspen.testing.client import Client [as 別名]
# 或者: from aspen.testing.client.Client import build_wsgi_environ [as 別名]
    def build_wsgi_environ(self, *a, **kw):
        """Extend base class to support authenticating as a certain user.
        """

        self.cookie.clear()

        # csrf - for both anon and authenticated
        csrf_token = kw.get('csrf_token', b'ThisIsATokenThatIsThirtyTwoBytes')
        if csrf_token:
            self.cookie[b'csrf_token'] = csrf_token
            kw[b'HTTP_X-CSRF-TOKEN'] = csrf_token

        # user authentication
        auth_as = kw.pop('auth_as', None)
        if auth_as:
            user.User.from_username(auth_as).sign_in(self.cookie)

        for k, v in kw.pop('cookies', {}).items():
            self.cookie[k] = v

        return Client.build_wsgi_environ(self, *a, **kw)
開發者ID:PeterDaveHello,項目名稱:gratipay.com,代碼行數:23,代碼來源:harness.py

示例3: build_wsgi_environ

# 需要導入模塊: from aspen.testing.client import Client [as 別名]
# 或者: from aspen.testing.client.Client import build_wsgi_environ [as 別名]
    def build_wsgi_environ(self, *a, **kw):
        """Extend base class to support authenticating as a certain user.
        """

        self.cookie.clear()

        # csrf - for both anon and authenticated
        csrf_token = kw.get('csrf_token', b'ThisIsATokenThatIsThirtyTwoBytes')
        if csrf_token:
            self.cookie[b'csrf_token'] = csrf_token
            kw[b'HTTP_X-CSRF-TOKEN'] = csrf_token

        # user authentication
        auth_as = kw.pop('auth_as', None)
        if auth_as:
            assert auth_as.session_token
            self.cookie[SESSION] = '%s:%s' % (auth_as.id, auth_as.session_token)

        # cookies
        for k, v in kw.pop('cookies', {}).items():
            self.cookie[k] = v

        return Client.build_wsgi_environ(self, *a, **kw)
開發者ID:fracolo,項目名稱:liberapay.com,代碼行數:25,代碼來源:__init__.py


注:本文中的aspen.testing.client.Client.build_wsgi_environ方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。