comparison mercurial/hgweb/hgweb_mod.py @ 2506:d0db3462d568

This patch make several WSGI related alterations. First, it changes the server to be almost a generic WSGI server. Second, it changes request.py to have wsgiapplication and _wsgirequest. wsgiapplication is a class that creates _wsgirequests when called by a WSGI compliant server. It needs to know whether or not it should create hgwebdir or hgweb requests. Lastly, wsgicgi.py is added, and the CGI scripts are altered to use it to launch wsgiapplications in a WSGI compliant way. As a side effect, all the keepalive code has been removed from request.py. This code needs to be moved so that it is exclusively in server.py
author Eric Hopper <hopper@omnifarious.org>
date Tue, 27 Jun 2006 00:09:33 -0700
parents e10665147d26
children 6350b01d173f
comparison
equal deleted inserted replaced
2505:01b856927970 2506:d0db3462d568
10 import os.path 10 import os.path
11 import mimetypes 11 import mimetypes
12 from mercurial.demandload import demandload 12 from mercurial.demandload import demandload
13 demandload(globals(), "re zlib ConfigParser cStringIO sys tempfile") 13 demandload(globals(), "re zlib ConfigParser cStringIO sys tempfile")
14 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,templater") 14 demandload(globals(), "mercurial:mdiff,ui,hg,util,archival,templater")
15 demandload(globals(), "mercurial.hgweb.request:hgrequest")
16 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile") 15 demandload(globals(), "mercurial.hgweb.common:get_mtime,staticfile")
17 from mercurial.node import * 16 from mercurial.node import *
18 from mercurial.i18n import gettext as _ 17 from mercurial.i18n import gettext as _
19 18
20 def _up(p): 19 def _up(p):
650 p = util.normpath(path) 649 p = util.normpath(path)
651 if p[:2] == "..": 650 if p[:2] == "..":
652 raise Exception("suspicious path") 651 raise Exception("suspicious path")
653 return p 652 return p
654 653
655 def run(self, req=hgrequest()): 654 def run(self, req):
656 def header(**map): 655 def header(**map):
657 yield self.t("header", **map) 656 yield self.t("header", **map)
658 657
659 def footer(**map): 658 def footer(**map):
660 yield self.t("footer", 659 yield self.t("footer",
723 method = getattr(self, 'do_' + cmd, None) 722 method = getattr(self, 'do_' + cmd, None)
724 if method: 723 if method:
725 method(req) 724 method(req)
726 else: 725 else:
727 req.write(self.t("error")) 726 req.write(self.t("error"))
728 req.done()
729 727
730 def do_changelog(self, req): 728 def do_changelog(self, req):
731 hi = self.repo.changelog.count() - 1 729 hi = self.repo.changelog.count() - 1
732 if req.form.has_key('rev'): 730 if req.form.has_key('rev'):
733 hi = req.form['rev'][0] 731 hi = req.form['rev'][0]