diff hgext/highlight/__init__.py @ 36880:67fb0dca29bc

hgweb: always return iterable from @webcommand functions (API) We had to hack up this function to support our transition to the new response API. Now that we're done with the transition (!!), we can return to returning an iterator of content chunks from these functions. It is tempting to return a normal object and not a generator. However, as the keyword extension demonstrates, extensions may wish to wrap commands and have a try..finally block around execution. Since there is a generator producing content and that generator could be executing code, the try..finally needs to live for as long as the generator is running. That means we have to return a generator so wrappers can consume the generator inside a try..finally. .. api:: hgweb @webcommand functions must use the new response object passed in via ``web.res`` to initiate sending of a response. The hgweb WSGI application will no longer start sending the response automatically. Differential Revision: https://phab.mercurial-scm.org/D2796
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 20:35:35 -0800
parents 9fc3d814646e
children ece242db5000
line wrap: on
line diff
--- a/hgext/highlight/__init__.py	Sat Mar 10 18:51:32 2018 -0800
+++ b/hgext/highlight/__init__.py	Sat Mar 10 20:35:35 2018 -0800
@@ -88,7 +88,7 @@
         '/* pygments_style = %s */\n\n' % pg_style,
         fmter.get_style_defs(''),
     ]))
-    return web.res
+    return web.res.sendresponse()
 
 def extsetup():
     # monkeypatch in the new version