本文整理汇总了Python中pyramid.response.Response.headers[str(header)]方法的典型用法代码示例。如果您正苦于以下问题:Python Response.headers[str(header)]方法的具体用法?Python Response.headers[str(header)]怎么用?Python Response.headers[str(header)]使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyramid.response.Response
的用法示例。
在下文中一共展示了Response.headers[str(header)]方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: displayResponse
# 需要导入模块: from pyramid.response import Response [as 别名]
# 或者: from pyramid.response.Response import headers[str(header)] [as 别名]
def displayResponse(request, openid_response):
""" Display an OpenID response.
Errors will be displayed directly to the user.
Successful responses and other protocol-level messages will be sent
using the proper mechanism (i.e., direct response, redirection, etc.).
"""
s = getServer(request)
# Encode the response into something that is renderable.
try:
webresponse = s.encodeResponse(openid_response)
except EncodingError as why:
# If it couldn't be encoded, display an error.
text = why.response.encodeToKVForm()
return render_to_response('templates/endpoint.pt',
dict(main_template=main_template(),
error=text,
),
request=request)
# Construct and return a response onbject
r = Response(body=webresponse.body)
r.status = webresponse.code #XXX int vs. str?
for header, value in webresponse.headers.iteritems():
r.headers[str(header)] = str(value)
return r