##// END OF EJS Templates
hgweb: fix breaking tests on Python < 2.5
Bryan O'Sullivan -
r5563:d61fea13 default
parent child Browse files
Show More
@@ -12,11 +12,18 b' class ErrorResponse(Exception):'
12 def __init__(self, code, message=None):
12 def __init__(self, code, message=None):
13 Exception.__init__(self)
13 Exception.__init__(self)
14 self.code = code
14 self.code = code
15 if message is None:
15 if message:
16 from httplib import responses
16 self.message = message
17 self.message = responses.get(code, 'Error')
18 else:
17 else:
19 self.message = message
18 self.message = _statusmessage(code)
19
20 def _statusmessage(code):
21 from BaseHTTPServer import BaseHTTPRequestHandler
22 responses = BaseHTTPRequestHandler.responses
23 return responses.get(code, ('Error', 'Unknown error'))[0]
24
25 def statusmessage(code):
26 return '%d %s' % (code, _statusmessage(code))
20
27
21 def get_mtime(repo_path):
28 def get_mtime(repo_path):
22 store_path = os.path.join(repo_path, ".hg")
29 store_path = os.path.join(repo_path, ".hg")
@@ -13,6 +13,7 b' from mercurial.i18n import gettext as _'
13 from mercurial import mdiff, ui, hg, util, archival, streamclone, patch
13 from mercurial import mdiff, ui, hg, util, archival, streamclone, patch
14 from mercurial import revlog, templater
14 from mercurial import revlog, templater
15 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen
15 from common import ErrorResponse, get_mtime, staticfile, style_map, paritygen
16 from common import statusmsg
16
17
17 def _up(p):
18 def _up(p):
18 if p[0] != "/":
19 if p[0] != "/":
@@ -8,7 +8,7 b''
8
8
9 import socket, cgi, errno
9 import socket, cgi, errno
10 from mercurial.i18n import gettext as _
10 from mercurial.i18n import gettext as _
11 from common import ErrorResponse
11 from common import ErrorResponse, statusmessage
12
12
13 class wsgiapplication(object):
13 class wsgiapplication(object):
14 def __init__(self, destmaker):
14 def __init__(self, destmaker):
@@ -53,15 +53,10 b' class _wsgirequest(object):'
53 if self.server_write is None:
53 if self.server_write is None:
54 if not self.headers:
54 if not self.headers:
55 raise RuntimeError("request.write called before headers sent (%s)." % thing)
55 raise RuntimeError("request.write called before headers sent (%s)." % thing)
56 code = None
57 if isinstance(status, ErrorResponse):
56 if isinstance(status, ErrorResponse):
58 code = status.code
57 status = statusmessage(status.code)
59 elif isinstance(status, int):
58 elif isinstance(status, int):
60 code = status
59 status = statusmessage(status)
61 if code:
62 from httplib import responses
63 status = '%d %s' % (
64 code, responses.get(code, 'Error'))
65 self.server_write = self.start_response(status,
60 self.server_write = self.start_response(status,
66 self.headers)
61 self.headers)
67 self.start_response = None
62 self.start_response = None
General Comments 0
You need to be logged in to leave comments. Login now