Pass the original request object to Tornado's finish().

This is preparatory for running the Django response middleware on
our Tornado responses.

(imported from commit 05da8ea9cb663a928b2f98a928f3992aae4f067c)
This commit is contained in:
Tim Abbott 2013-03-14 16:43:04 -04:00
parent a495b0dfa6
commit 549577a928
2 changed files with 6 additions and 4 deletions

View File

@ -325,7 +325,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
return response
def finish(self, response=None, apply_markdown=True):
def finish(self, response=None, request=None, apply_markdown=True):
superself = super(AsyncDjangoHandler, self)
if not isinstance(response, dict):
return superself.finish(response)
@ -342,4 +342,5 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
return superself.finish('Internal error: bad message format')
if response['result'] == 'error':
self.set_status(400)
return superself.finish(response)

View File

@ -362,7 +362,7 @@ def get_updates_backend(request, user_profile, handler, client_id,
dont_block, stream_name,
apply_markdown=apply_markdown, **kwargs)
if resp is not None:
handler.finish(resp, apply_markdown)
handler.finish(resp, request=request, apply_markdown=apply_markdown)
# We have already invoked handler.finish(), so we bypass the usual view
# response path. We are "responding asynchronously" except that it
@ -394,7 +394,8 @@ def get_updates_backend(request, user_profile, handler, client_id,
# must do it by making a new request
handler.finish({"result": "success",
"msg": "",
'update_types': []})
'update_types': []},
request=request)
return
kwargs.update(cb_kwargs)
@ -402,7 +403,7 @@ def get_updates_backend(request, user_profile, handler, client_id,
client_server_generation=client_server_generation,
apply_markdown=apply_markdown,
**kwargs)
handler.finish(res, apply_markdown)
handler.finish(res, request=request, apply_markdown=apply_markdown)
except socket.error:
pass