本文整理汇总了Python中twisted.web.server.Request.render方法的典型用法代码示例。如果您正苦于以下问题:Python Request.render方法的具体用法?Python Request.render怎么用?Python Request.render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twisted.web.server.Request
的用法示例。
在下文中一共展示了Request.render方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: render
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import render [as 别名]
def render(self, resrc):
# this is called once a Resource has been found to serve the request; in our
# case the Resource in question will normally be a JsonResource.
# create a LogContext for this request
request_id = self.get_request_id()
logcontext = self.logcontext = LoggingContext(request_id)
logcontext.request = request_id
# override the Server header which is set by twisted
self.setHeader("Server", self.site.server_version_string)
with PreserveLoggingContext(self.logcontext):
# we start the request metrics timer here with an initial stab
# at the servlet name. For most requests that name will be
# JsonResource (or a subclass), and JsonResource._async_render
# will update it once it picks a servlet.
servlet_name = resrc.__class__.__name__
self._started_processing(servlet_name)
Request.render(self, resrc)
# record the arrival of the request *after*
# dispatching to the handler, so that the handler
# can update the servlet name in the request
# metrics
requests_counter.labels(self.get_method(),
self.request_metrics.name).inc()
示例2: render
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import render [as 别名]
def render(self, resource):
"""Renders identified resource and write response"""
CORE.info('Rendering resource...')
try:
body = resource.render(self)
except NotAuthenticated:
body = None
self.setResponseCode(BAD_REQUEST_UNAUTH) # HTTP FIXME
except UnsupportedMethod:
Request.render(self, resource) # use twisteds error handling
return
if body is NOT_DONE_YET:
return
self.respond(body)
示例3: render
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import render [as 别名]
def render(self, resrc):
# override the Server header which is set by twisted
self.setHeader("Server", self.site.server_version_string)
return Request.render(self, resrc)
示例4: render
# 需要导入模块: from twisted.web.server import Request [as 别名]
# 或者: from twisted.web.server.Request import render [as 别名]
def render(self, resource):
# NOTE(kgriffs): Override render, instead of process, to ensure
# that we have the last say in the value of the headers.
self._inject_headers()
Request.render(self, resource)