mirror of https://github.com/zulip/zulip.git
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:
parent
a495b0dfa6
commit
549577a928
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue