avoid wsgiapplication <-> MercurialHTTPServer circular reference
authorAlexis S. L. Carvalho <alexis@cecm.usp.br>
Mon, 19 Mar 2007 19:07:38 -0300
changeset 4245 bd46b83b9692
parent 4244 a80502f47552
child 4246 cc81c512a531
avoid wsgiapplication <-> MercurialHTTPServer circular reference
mercurial/hgweb/server.py
--- a/mercurial/hgweb/server.py	Mon Mar 19 19:07:37 2007 -0300
+++ b/mercurial/hgweb/server.py	Mon Mar 19 19:07:38 2007 -0300
@@ -206,12 +206,17 @@
             BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs)
             self.accesslog = accesslog
             self.errorlog = errorlog
-            self.repo = repo
-            self.webdir_conf = webdir_conf
-            self.webdirmaker = hgwebdir
-            self.repoviewmaker = hgweb
-            self.reqmaker = wsgiapplication(self.make_handler)
             self.daemon_threads = True
+            def make_handler():
+                if webdir_conf:
+                    hgwebobj = hgwebdir(webdir_conf, ui)
+                elif repo is not None:
+                    hgwebobj = hgweb(hg.repository(repo.ui, repo.root))
+                else:
+                    raise hg.RepoError(_("There is no Mercurial repository here"
+                                         " (.hg not found)"))
+                return hgwebobj
+            self.reqmaker = wsgiapplication(make_handler)
 
             addr, port = self.socket.getsockname()[:2]
             if addr in ('0.0.0.0', '::'):
@@ -223,17 +228,6 @@
                     pass
             self.addr, self.port = addr, port
 
-        def make_handler(self):
-            if self.webdir_conf:
-                hgwebobj = self.webdirmaker(self.webdir_conf, ui)
-            elif self.repo is not None:
-                hgwebobj = self.repoviewmaker(hg.repository(repo.ui,
-                                                            repo.root))
-            else:
-                raise hg.RepoError(_("There is no Mercurial repository here"
-                                     " (.hg not found)"))
-            return hgwebobj
-
     class IPv6HTTPServer(MercurialHTTPServer):
         address_family = getattr(socket, 'AF_INET6', None)