changeset 2538:f4b7d71c1c60

Cleanup hgweb and hgwebdir's run method a bit.
author Eric Hopper <hopper@omnifarious.org>
date Fri, 30 Jun 2006 09:50:25 -0700
parents b6975008d44f
children 8a8d9ada4528
files mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py
diffstat 2 files changed, 4 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -651,12 +651,12 @@ class hgweb(object):
         return p
 
     def run(self):
-        if os.environ['GATEWAY_INTERFACE'][0:6] != "CGI/1.":
+        if not os.environ.get('GATEWAY_INTERFACE', '').startswith("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)
+            return self
         wsgicgi.launch(wsgiapplication(make_web_app))
 
     def run_wsgi(self, req):
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -20,7 +20,6 @@ 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)):
@@ -48,12 +47,12 @@ class hgwebdir(object):
             self.repos.sort()
 
     def run(self):
-        if os.environ['GATEWAY_INTERFACE'][0:6] != "CGI/1.":
+        if not os.environ.get('GATEWAY_INTERFACE', '').startswith("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)
+            return self
         wsgicgi.launch(wsgiapplication(make_web_app))
 
     def run_wsgi(self, req):