Mercurial > public > mercurial-scm > hg-stable
diff mercurial/hgweb/hgwebdir_mod.py @ 6785:4879468fa28f
hgweb: return content iterator instead of using write() callable
author | Dirkjan Ochtman <dirkjan@ochtman.nl> |
---|---|
date | Sun, 29 Jun 2008 22:36:18 +0200 |
parents | f67d1468ac50 |
children | 943f066c0d58 |
line wrap: on
line diff
--- a/mercurial/hgweb/hgwebdir_mod.py Sun Jun 29 15:23:09 2008 +0200 +++ b/mercurial/hgweb/hgwebdir_mod.py Sun Jun 29 22:36:18 2008 +0200 @@ -70,8 +70,7 @@ def __call__(self, env, respond): req = wsgirequest(env, respond) - self.run_wsgi(req) - return req + return self.run_wsgi(req) def run_wsgi(self, req): @@ -90,14 +89,12 @@ fname = virtual[7:] else: fname = req.form['static'][0] - req.write(staticfile(static, fname, req)) - return + return staticfile(static, fname, req), # top-level index elif not virtual: req.respond(HTTP_OK, ctype) - req.write(self.makeindex(req, tmpl)) - return + return ''.join(self.makeindex(req, tmpl)), # nested indexes and hgwebs @@ -108,8 +105,7 @@ req.env['REPO_NAME'] = virtual try: repo = hg.repository(self.parentui, real) - hgweb(repo).run_wsgi(req) - return + return hgweb(repo).run_wsgi(req) except IOError, inst: msg = inst.strerror raise ErrorResponse(HTTP_SERVER_ERROR, msg) @@ -120,8 +116,7 @@ subdir = virtual + '/' if [r for r in repos if r.startswith(subdir)]: req.respond(HTTP_OK, ctype) - req.write(self.makeindex(req, tmpl, subdir)) - return + return ''.join(self.makeindex(req, tmpl, subdir)), up = virtual.rfind('/') if up < 0: @@ -130,11 +125,11 @@ # prefixes not found req.respond(HTTP_NOT_FOUND, ctype) - req.write(tmpl("notfound", repo=virtual)) + return ''.join(tmpl("notfound", repo=virtual)), except ErrorResponse, err: req.respond(err.code, ctype) - req.write(tmpl('error', error=err.message or '')) + return ''.join(tmpl('error', error=err.message or '')), finally: tmpl = None