Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/server.py @ 10642:812b85d02c92
server: pass wsgi application to server (no need for non-local var)
author | Dirkjan Ochtman <djc.ochtman@kentyde.com> |
---|---|
date | Thu, 11 Mar 2010 13:32:26 +0100 |
parents | dedf88fe945a |
children | 1874697a8863 |
comparison
equal
deleted
inserted
replaced
10641:dedf88fe945a | 10642:812b85d02c92 |
---|---|
216 myui = ui | 216 myui = ui |
217 else: | 217 else: |
218 myui = repo.ui | 218 myui = repo.ui |
219 address = myui.config("web", "address", "") | 219 address = myui.config("web", "address", "") |
220 port = int(myui.config("web", "port", 8000)) | 220 port = int(myui.config("web", "port", 8000)) |
221 webdir_conf = myui.config("web", "webdir_conf") | |
222 | |
223 if webdir_conf: | |
224 hgwebobj = hgwebdir(webdir_conf, ui) | |
225 elif repo is not None: | |
226 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | |
227 else: | |
228 raise error.RepoError(_("There is no Mercurial repository" | |
229 " here (.hg not found)")) | |
230 | 221 |
231 class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer): | 222 class MercurialHTTPServer(object, _mixin, BaseHTTPServer.HTTPServer): |
232 | 223 |
233 # SO_REUSEADDR has broken semantics on windows | 224 # SO_REUSEADDR has broken semantics on windows |
234 if os.name == 'nt': | 225 if os.name == 'nt': |
235 allow_reuse_address = 0 | 226 allow_reuse_address = 0 |
236 | 227 |
237 def __init__(self, ui, *args, **kargs): | 228 def __init__(self, ui, app, *args, **kargs): |
238 BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs) | 229 BaseHTTPServer.HTTPServer.__init__(self, *args, **kargs) |
239 self.daemon_threads = True | 230 self.daemon_threads = True |
240 self.application = hgwebobj | 231 self.application = app |
241 | 232 |
242 ssl_cert = ui.config('web', 'certificate') | 233 ssl_cert = ui.config('web', 'certificate') |
243 if ssl_cert: | 234 if ssl_cert: |
244 try: | 235 try: |
245 from OpenSSL import SSL | 236 from OpenSSL import SSL |
282 if myui.configbool('web', 'ipv6'): | 273 if myui.configbool('web', 'ipv6'): |
283 cls = IPv6HTTPServer | 274 cls = IPv6HTTPServer |
284 else: | 275 else: |
285 cls = MercurialHTTPServer | 276 cls = MercurialHTTPServer |
286 | 277 |
278 webdir_conf = myui.config("web", "webdir_conf") | |
279 if webdir_conf: | |
280 hgwebobj = hgwebdir(webdir_conf, ui) | |
281 elif repo is not None: | |
282 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | |
283 else: | |
284 raise error.RepoError(_("There is no Mercurial repository" | |
285 " here (.hg not found)")) | |
286 | |
287 # ugly hack due to python issue5853 (for threaded use) | 287 # ugly hack due to python issue5853 (for threaded use) |
288 import mimetypes; mimetypes.init() | 288 import mimetypes; mimetypes.init() |
289 | 289 |
290 try: | 290 try: |
291 return cls(myui, (address, port), handler) | 291 return cls(myui, hgwebobj, (address, port), handler) |
292 except socket.error, inst: | 292 except socket.error, inst: |
293 raise util.Abort(_("cannot start server at '%s:%d': %s") | 293 raise util.Abort(_("cannot start server at '%s:%d': %s") |
294 % (address, port, inst.args[1])) | 294 % (address, port, inst.args[1])) |