Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 2535:b8ccf6386db7
Arrange for old copies of CGI scripts to still work.
author | Eric Hopper <hopper@omnifarious.org> |
---|---|
date | Thu, 29 Jun 2006 19:06:18 -0700 |
parents | 419c42223bee |
children | b6975008d44f |
comparison
equal
deleted
inserted
replaced
2534:d5a3cc6520d5 | 2535:b8ccf6386db7 |
---|---|
18 class hgwebdir(object): | 18 class hgwebdir(object): |
19 def __init__(self, config): | 19 def __init__(self, config): |
20 def cleannames(items): | 20 def cleannames(items): |
21 return [(name.strip(os.sep), path) for name, path in items] | 21 return [(name.strip(os.sep), path) for name, path in items] |
22 | 22 |
23 self.origconfig = config | |
23 self.motd = "" | 24 self.motd = "" |
24 self.repos_sorted = ('name', False) | 25 self.repos_sorted = ('name', False) |
25 if isinstance(config, (list, tuple)): | 26 if isinstance(config, (list, tuple)): |
26 self.repos = cleannames(config) | 27 self.repos = cleannames(config) |
27 self.repos_sorted = ('', False) | 28 self.repos_sorted = ('', False) |
44 if name.startswith(prefix): | 45 if name.startswith(prefix): |
45 name = name[len(prefix):] | 46 name = name[len(prefix):] |
46 self.repos.append((name.lstrip(os.sep), repo)) | 47 self.repos.append((name.lstrip(os.sep), repo)) |
47 self.repos.sort() | 48 self.repos.sort() |
48 | 49 |
49 def run(self, req): | 50 def run(self): |
51 if os.environ['GATEWAY_INTERFACE'][0:6] != "CGI/1.": | |
52 raise RuntimeError("This function is only intended to be called while running as a CGI script.") | |
53 import mercurial.hgweb.wsgicgi as wsgicgi | |
54 from request import wsgiapplication | |
55 def make_web_app(): | |
56 return self.__class__(self.origconfig) | |
57 wsgicgi.launch(wsgiapplication(make_web_app)) | |
58 | |
59 def run_wsgi(self, req): | |
50 def header(**map): | 60 def header(**map): |
51 header_file = cStringIO.StringIO(''.join(tmpl("header", **map))) | 61 header_file = cStringIO.StringIO(''.join(tmpl("header", **map))) |
52 msg = mimetools.Message(header_file, 0) | 62 msg = mimetools.Message(header_file, 0) |
53 req.header(msg.items()) | 63 req.header(msg.items()) |
54 yield header_file.read() | 64 yield header_file.read() |