comparison mercurial/hgweb/hgweb_mod.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 feac5b0bf9ba
children 9c7f543405c1 e15f7db0f0ee
comparison
equal deleted inserted replaced
5565:feac5b0bf9ba 5566:d74fc8dec2b4
11 from mercurial.node import * 11 from mercurial.node import *
12 from mercurial.i18n import gettext as _ 12 from mercurial.i18n import gettext as _
13 from mercurial import mdiff, ui, hg, util, archival, streamclone, patch 13 from mercurial import mdiff, ui, hg, util, archival, streamclone, patch
14 from mercurial import revlog, templater 14 from mercurial import revlog, templater
15 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen 15 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen
16 from request import wsgirequest
16 17
17 def _up(p): 18 def _up(p):
18 if p[0] != "/": 19 if p[0] != "/":
19 p = "/" + p 20 p = "/" + p
20 if p[-1] == "/": 21 if p[-1] == "/":
669 670
670 def run(self): 671 def run(self):
671 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."): 672 if not os.environ.get('GATEWAY_INTERFACE', '').startswith("CGI/1."):
672 raise RuntimeError("This function is only intended to be called while running as a CGI script.") 673 raise RuntimeError("This function is only intended to be called while running as a CGI script.")
673 import mercurial.hgweb.wsgicgi as wsgicgi 674 import mercurial.hgweb.wsgicgi as wsgicgi
674 from request import wsgiapplication 675 wsgicgi.launch(self)
675 def make_web_app(): 676
676 return self 677 def __call__(self, env, respond):
677 wsgicgi.launch(wsgiapplication(make_web_app)) 678 req = wsgirequest(env, respond)
679 self.run_wsgi(req)
680 return req
678 681
679 def run_wsgi(self, req): 682 def run_wsgi(self, req):
680 def header(**map): 683 def header(**map):
681 header_file = cStringIO.StringIO( 684 header_file = cStringIO.StringIO(
682 ''.join(self.t("header", encoding=self.encoding, **map))) 685 ''.join(self.t("header", encoding=self.encoding, **map)))