197 ext = spec[2] |
197 ext = spec[2] |
198 if fn.endswith(ext): |
198 if fn.endswith(ext): |
199 req.form['node'] = [fn[:-len(ext)]] |
199 req.form['node'] = [fn[:-len(ext)]] |
200 req.form['type'] = [type_] |
200 req.form['type'] = [type_] |
201 |
201 |
202 # actually process the request |
202 # process this if it's a protocol request |
|
203 |
|
204 cmd = req.form.get('cmd', [''])[0] |
|
205 if cmd in protocol.__all__: |
|
206 method = getattr(protocol, cmd) |
|
207 method(self, req) |
|
208 return |
|
209 |
|
210 # process the web interface request |
203 |
211 |
204 try: |
212 try: |
205 |
213 |
206 cmd = req.form.get('cmd', [''])[0] |
214 tmpl = self.templater(req) |
207 if cmd in protocol.__all__: |
215 ctype = tmpl('mimetype', encoding=self.encoding) |
208 method = getattr(protocol, cmd) |
216 ctype = templater.stringify(ctype) |
209 method(self, req) |
217 |
|
218 if cmd == '': |
|
219 req.form['cmd'] = [tmpl.cache['default']] |
|
220 cmd = req.form['cmd'][0] |
|
221 |
|
222 if cmd not in webcommands.__all__: |
|
223 msg = 'No such method: %s' % cmd |
|
224 raise ErrorResponse(HTTP_BAD_REQUEST, msg) |
|
225 elif cmd == 'file' and 'raw' in req.form.get('style', []): |
|
226 self.ctype = ctype |
|
227 content = webcommands.rawfile(self, req, tmpl) |
210 else: |
228 else: |
211 tmpl = self.templater(req) |
229 content = getattr(webcommands, cmd)(self, req, tmpl) |
212 ctype = tmpl('mimetype', encoding=self.encoding) |
230 req.respond(HTTP_OK, ctype) |
213 ctype = templater.stringify(ctype) |
231 |
214 |
232 req.write(content) |
215 if cmd == '': |
233 del tmpl |
216 req.form['cmd'] = [tmpl.cache['default']] |
|
217 cmd = req.form['cmd'][0] |
|
218 |
|
219 if cmd not in webcommands.__all__: |
|
220 msg = 'No such method: %s' % cmd |
|
221 raise ErrorResponse(HTTP_BAD_REQUEST, msg) |
|
222 elif cmd == 'file' and 'raw' in req.form.get('style', []): |
|
223 self.ctype = ctype |
|
224 content = webcommands.rawfile(self, req, tmpl) |
|
225 else: |
|
226 content = getattr(webcommands, cmd)(self, req, tmpl) |
|
227 req.respond(HTTP_OK, ctype) |
|
228 |
|
229 req.write(content) |
|
230 del tmpl |
|
231 |
234 |
232 except revlog.LookupError, err: |
235 except revlog.LookupError, err: |
233 req.respond(HTTP_NOT_FOUND, ctype) |
236 req.respond(HTTP_NOT_FOUND, ctype) |
234 req.write(tmpl('error', error='revision not found: %s' % err.name)) |
237 req.write(tmpl('error', error='revision not found: %s' % err.name)) |
235 except (hg.RepoError, revlog.RevlogError), inst: |
238 except (hg.RepoError, revlog.RevlogError), inst: |