[PATCH 4 of 4] Arrange for old copies of CGI scripts to still work

Eric Hopper hopper at omnifarious.org
Thu Jun 29 21:15:13 CDT 2006


# HG changeset patch
# User Eric Hopper <hopper at omnifarious.org>
# Node ID b8ccf6386db7e60619713f6f7446f939e3e11faf
# Parent  d5a3cc6520d550fe9e96f9f3ac9da9a63008260f
Arrange for old copies of CGI scripts to still work.

diff -r d5a3cc6520d5 -r b8ccf6386db7 mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py	Thu Jun 29 18:34:26 2006 -0700
+++ b/mercurial/hgweb/hgweb_mod.py	Thu Jun 29 19:06:18 2006 -0700
@@ -650,7 +650,16 @@ class hgweb(object):
             raise Exception("suspicious path")
         return p
 
-    def run(self, req):
+    def run(self):
+        if os.environ['GATEWAY_INTERFACE'][0:6] != "CGI/1.":
+            raise RuntimeError("This function is only intended to be called while running as a CGI script.")
+        import mercurial.hgweb.wsgicgi as wsgicgi
+        from request import wsgiapplication
+        def make_web_app():
+            return self.__class__(self.repo, self.reponame)
+        wsgicgi.launch(wsgiapplication(make_web_app))
+
+    def run_wsgi(self, req):
         def header(**map):
             header_file = cStringIO.StringIO(''.join(self.t("header", **map)))
             msg = mimetools.Message(header_file, 0)
diff -r d5a3cc6520d5 -r b8ccf6386db7 mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py	Thu Jun 29 18:34:26 2006 -0700
+++ b/mercurial/hgweb/hgwebdir_mod.py	Thu Jun 29 19:06:18 2006 -0700
@@ -20,6 +20,7 @@ class hgwebdir(object):
         def cleannames(items):
             return [(name.strip(os.sep), path) for name, path in items]
 
+        self.origconfig = config
         self.motd = ""
         self.repos_sorted = ('name', False)
         if isinstance(config, (list, tuple)):
@@ -46,7 +47,16 @@ class hgwebdir(object):
                         self.repos.append((name.lstrip(os.sep), repo))
             self.repos.sort()
 
-    def run(self, req):
+    def run(self):
+        if os.environ['GATEWAY_INTERFACE'][0:6] != "CGI/1.":
+            raise RuntimeError("This function is only intended to be called while running as a CGI script.")
+        import mercurial.hgweb.wsgicgi as wsgicgi
+        from request import wsgiapplication
+        def make_web_app():
+            return self.__class__(self.origconfig)
+        wsgicgi.launch(wsgiapplication(make_web_app))
+
+    def run_wsgi(self, req):
         def header(**map):
             header_file = cStringIO.StringIO(''.join(tmpl("header", **map)))
             msg = mimetools.Message(header_file, 0)
diff -r d5a3cc6520d5 -r b8ccf6386db7 mercurial/hgweb/request.py
--- a/mercurial/hgweb/request.py	Thu Jun 29 18:34:26 2006 -0700
+++ b/mercurial/hgweb/request.py	Thu Jun 29 19:06:18 2006 -0700
@@ -48,7 +48,7 @@ class _wsgirequest(object):
         self.form = cgi.parse(self.inp, self.env, keep_blank_values=1)
         self.start_response = start_response
         self.headers = []
-        destination.run(self)
+        destination.run_wsgi(self)
 
     def __iter__(self):
         return iter([])
diff -r d5a3cc6520d5 -r b8ccf6386db7 mercurial/templater.py
--- a/mercurial/templater.py	Thu Jun 29 18:34:26 2006 -0700
+++ b/mercurial/templater.py	Thu Jun 29 19:06:18 2006 -0700
@@ -202,7 +202,7 @@ def fill(text, width):
     if para_re is None:
         para_re = re.compile('(\n\n|\n\\s*[-*]\\s*)', re.M)
         space_re = re.compile(r'  +')
-        
+
     def findparas():
         start = 0
         while True:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.selenic.com/pipermail/mercurial/attachments/20060629/d446c10b/attachment.pgp


More information about the Mercurial mailing list