Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/server.py @ 10638:92209ae8610a
server: externalize application creation
author | Dirkjan Ochtman <djc.ochtman@kentyde.com> |
---|---|
date | Thu, 11 Mar 2010 11:21:48 +0100 |
parents | 25e572394f5c |
children | a6808629f450 |
comparison
equal
deleted
inserted
replaced
10636:23ab3b05bd66 | 10638:92209ae8610a |
---|---|
231 _mixin = SocketServer.ForkingMixIn | 231 _mixin = SocketServer.ForkingMixIn |
232 else: | 232 else: |
233 class _mixin: | 233 class _mixin: |
234 pass | 234 pass |
235 | 235 |
236 if webdir_conf: | |
237 hgwebobj = hgwebdir(webdir_conf, ui) | |
238 elif repo is not None: | |
239 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | |
240 else: | |
241 raise error.RepoError(_("There is no Mercurial repository" | |
242 " here (.hg not found)")) | |
243 | |
236 class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer): | 244 class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer): |
237 | 245 |
238 # SO_REUSEADDR has broken semantics on windows | 246 # SO_REUSEADDR has broken semantics on windows |
239 if os.name == 'nt': | 247 if os.name == 'nt': |
240 allow_reuse_address = 0 | 248 allow_reuse_address = 0 |
242 def __init__(self, *args, **kargs): | 250 def __init__(self, *args, **kargs): |
243 BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs) | 251 BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs) |
244 self.accesslog = accesslog | 252 self.accesslog = accesslog |
245 self.errorlog = errorlog | 253 self.errorlog = errorlog |
246 self.daemon_threads = True | 254 self.daemon_threads = True |
247 def make_handler(): | 255 self.application = hgwebobj |
248 if webdir_conf: | |
249 hgwebobj = hgwebdir(webdir_conf, ui) | |
250 elif repo is not None: | |
251 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | |
252 else: | |
253 raise error.RepoError(_("There is no Mercurial repository" | |
254 " here (.hg not found)")) | |
255 return hgwebobj | |
256 self.application = make_handler() | |
257 | 256 |
258 if ssl_cert: | 257 if ssl_cert: |
259 try: | 258 try: |
260 from OpenSSL import SSL | 259 from OpenSSL import SSL |
261 ctx = SSL.Context(SSL.SSLv23_METHOD) | 260 ctx = SSL.Context(SSL.SSLv23_METHOD) |