Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/request.py @ 5566:d74fc8dec2b4
Less indirection in the WSGI web interface. This simplifies some code, and makes it more compliant with WSGI.
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Fri, 30 Nov 2007 18:23:18 +0100 |
parents | d61fea133f2d |
children | 0145f9afb0e7 |
line wrap: on
line diff
--- a/mercurial/hgweb/request.py Wed Nov 28 13:58:31 2007 -0800 +++ b/mercurial/hgweb/request.py Fri Nov 30 18:23:18 2007 +0100 @@ -10,15 +10,8 @@ from mercurial.i18n import gettext as _ from common import ErrorResponse, statusmessage -class wsgiapplication(object): - def __init__(self, destmaker): - self.destmaker = destmaker - - def __call__(self, wsgienv, start_response): - return _wsgirequest(self.destmaker(), wsgienv, start_response) - -class _wsgirequest(object): - def __init__(self, destination, wsgienv, start_response): +class wsgirequest(object): + def __init__(self, wsgienv, start_response): version = wsgienv['wsgi.version'] if (version < (1, 0)) or (version >= (2, 0)): raise RuntimeError("Unknown and unsupported WSGI version %d.%d" @@ -33,7 +26,6 @@ self.form = cgi.parse(self.inp, self.env, keep_blank_values=1) self.start_response = start_response self.headers = [] - destination.run_wsgi(self) out = property(lambda self: self) @@ -92,3 +84,9 @@ if length: headers.append(('Content-length', str(length))) self.header(headers) + +def wsgiapplication(app_maker): + application = app_maker() + def run_wsgi(env, respond): + application(env, respond) + return run_wsgi