comparison mercurial/hgweb/hgwebdir_mod.py @ 6797:8909070fd05e

merge another backout
author Dirkjan Ochtman <dirkjan@ochtman.nl>
date Wed, 02 Jul 2008 12:27:57 +0200
parents 943f066c0d58
children b77c25c2d6c0
comparison
equal deleted inserted replaced
6795:c228ae4bc89c 6797:8909070fd05e
87 static = os.path.join(templater.templatepath(), 'static') 87 static = os.path.join(templater.templatepath(), 'static')
88 if virtual.startswith('static/'): 88 if virtual.startswith('static/'):
89 fname = virtual[7:] 89 fname = virtual[7:]
90 else: 90 else:
91 fname = req.form['static'][0] 91 fname = req.form['static'][0]
92 return staticfile(static, fname, req), 92 req.write(staticfile(static, fname, req))
93 return []
93 94
94 # top-level index 95 # top-level index
95 elif not virtual: 96 elif not virtual:
96 req.respond(HTTP_OK, ctype) 97 req.respond(HTTP_OK, ctype)
97 return ''.join(self.makeindex(req, tmpl)), 98 req.write(self.makeindex(req, tmpl))
99 return []
98 100
99 # nested indexes and hgwebs 101 # nested indexes and hgwebs
100 102
101 repos = dict(self.repos) 103 repos = dict(self.repos)
102 while virtual: 104 while virtual:
114 116
115 # browse subdirectories 117 # browse subdirectories
116 subdir = virtual + '/' 118 subdir = virtual + '/'
117 if [r for r in repos if r.startswith(subdir)]: 119 if [r for r in repos if r.startswith(subdir)]:
118 req.respond(HTTP_OK, ctype) 120 req.respond(HTTP_OK, ctype)
119 return ''.join(self.makeindex(req, tmpl, subdir)), 121 req.write(self.makeindex(req, tmpl, subdir))
122 return []
120 123
121 up = virtual.rfind('/') 124 up = virtual.rfind('/')
122 if up < 0: 125 if up < 0:
123 break 126 break
124 virtual = virtual[:up] 127 virtual = virtual[:up]
125 128
126 # prefixes not found 129 # prefixes not found
127 req.respond(HTTP_NOT_FOUND, ctype) 130 req.respond(HTTP_NOT_FOUND, ctype)
128 return ''.join(tmpl("notfound", repo=virtual)), 131 req.write(tmpl("notfound", repo=virtual))
132 return []
129 133
130 except ErrorResponse, err: 134 except ErrorResponse, err:
131 req.respond(err.code, ctype) 135 req.respond(err.code, ctype)
132 return ''.join(tmpl('error', error=err.message or '')), 136 req.write(tmpl('error', error=err.message or ''))
137 return []
133 finally: 138 finally:
134 tmpl = None 139 tmpl = None
135 140
136 def makeindex(self, req, tmpl, subdir=""): 141 def makeindex(self, req, tmpl, subdir=""):
137 142