本文整理匯總了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)
示例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)
示例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)