Mercurial > public > mercurial-scm > hg
comparison mercurial/hgweb/server.py @ 10639:a6808629f450
server: externalize and streamline mixin setup
author | Dirkjan Ochtman <djc.ochtman@kentyde.com> |
---|---|
date | Thu, 11 Mar 2010 13:28:39 +0100 |
parents | 92209ae8610a |
children | 90a095c24bc4 |
comparison
equal
deleted
inserted
replaced
10638:92209ae8610a | 10639:a6808629f450 |
---|---|
193 super(_shgwebhandler, self).handle_one_request() | 193 super(_shgwebhandler, self).handle_one_request() |
194 except (SysCallError, ZeroReturnError): | 194 except (SysCallError, ZeroReturnError): |
195 self.close_connection = True | 195 self.close_connection = True |
196 pass | 196 pass |
197 | 197 |
198 try: | |
199 from threading import activeCount | |
200 _mixin = SocketServer.ThreadingMixIn | |
201 except ImportError: | |
202 if hasattr(os, "fork"): | |
203 _mixin = SocketServer.ForkingMixIn | |
204 else: | |
205 class _mixin: | |
206 pass | |
207 | |
198 def create_server(ui, repo): | 208 def create_server(ui, repo): |
199 use_threads = True | |
200 | 209 |
201 def openlog(opt, default): | 210 def openlog(opt, default): |
202 if opt and opt != '-': | 211 if opt and opt != '-': |
203 return open(opt, 'a') | 212 return open(opt, 'a') |
204 return default | 213 return default |
215 use_ipv6 = myui.configbool("web", "ipv6") | 224 use_ipv6 = myui.configbool("web", "ipv6") |
216 webdir_conf = myui.config("web", "webdir_conf") | 225 webdir_conf = myui.config("web", "webdir_conf") |
217 ssl_cert = myui.config("web", "certificate") | 226 ssl_cert = myui.config("web", "certificate") |
218 accesslog = openlog(myui.config("web", "accesslog", "-"), sys.stdout) | 227 accesslog = openlog(myui.config("web", "accesslog", "-"), sys.stdout) |
219 errorlog = openlog(myui.config("web", "errorlog", "-"), sys.stderr) | 228 errorlog = openlog(myui.config("web", "errorlog", "-"), sys.stderr) |
220 | |
221 if use_threads: | |
222 try: | |
223 from threading import activeCount | |
224 except ImportError: | |
225 use_threads = False | |
226 | |
227 if use_threads: | |
228 _mixin = SocketServer.ThreadingMixIn | |
229 else: | |
230 if hasattr(os, "fork"): | |
231 _mixin = SocketServer.ForkingMixIn | |
232 else: | |
233 class _mixin: | |
234 pass | |
235 | 229 |
236 if webdir_conf: | 230 if webdir_conf: |
237 hgwebobj = hgwebdir(webdir_conf, ui) | 231 hgwebobj = hgwebdir(webdir_conf, ui) |
238 elif repo is not None: | 232 elif repo is not None: |
239 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) | 233 hgwebobj = hgweb(hg.repository(repo.ui, repo.root)) |