当前位置: 首页>>代码示例>>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;未经允许,请勿转载。