##// END OF EJS Templates
hgweb: split out templater definition
Dirkjan Ochtman -
r5599:3de66c2a default
parent child Browse files
Show More
@@ -196,6 +196,37 b' class hgweb(object):'
196 req.form['node'] = [fn[:-len(ext)]]
196 req.form['node'] = [fn[:-len(ext)]]
197 req.form['type'] = [type_]
197 req.form['type'] = [type_]
198
198
199 # actually process the request
200
201 self.templater(req)
202 try:
203 if not req.form.has_key('cmd'):
204 req.form['cmd'] = [self.t.cache['default']]
205
206 cmd = req.form['cmd'][0]
207
208 try:
209 if hasattr(protocol, cmd):
210 method = getattr(protocol, cmd)
211 else:
212 method = getattr(webcommands, cmd)
213 method(self, req)
214 except revlog.LookupError, err:
215 req.respond(404, self.t(
216 'error', error='revision not found: %s' % err.name))
217 except (hg.RepoError, revlog.RevlogError), inst:
218 req.respond('500 Internal Server Error',
219 self.t('error', error=str(inst)))
220 except ErrorResponse, inst:
221 req.respond(inst.code, self.t('error', error=inst.message))
222 except AttributeError:
223 req.respond(400,
224 self.t('error', error='No such method: ' + cmd))
225 finally:
226 self.t = None
227
228 def templater(self, req):
229
199 # determine scheme, port and server name
230 # determine scheme, port and server name
200 # this is needed to create absolute urls
231 # this is needed to create absolute urls
201
232
@@ -247,6 +278,8 b' class hgweb(object):'
247 yield dict(name=name, value=value, separator=separator)
278 yield dict(name=name, value=value, separator=separator)
248 separator = ';'
279 separator = ';'
249
280
281 # figure out which style to use
282
250 style = self.config("web", "style", "")
283 style = self.config("web", "style", "")
251 if req.form.has_key('style'):
284 if req.form.has_key('style'):
252 style = req.form['style'][0]
285 style = req.form['style'][0]
@@ -257,6 +290,8 b' class hgweb(object):'
257 or req.env.get('REPO_NAME')
290 or req.env.get('REPO_NAME')
258 or req.url.strip('/') or self.repo.root)
291 or req.url.strip('/') or self.repo.root)
259
292
293 # create the templater
294
260 self.t = templater.templater(mapfile, templater.common_filters,
295 self.t = templater.templater(mapfile, templater.common_filters,
261 defaults={"url": req.url,
296 defaults={"url": req.url,
262 "staticurl": staticurl,
297 "staticurl": staticurl,
@@ -269,32 +304,6 b' class hgweb(object):'
269 "sessionvars": sessionvars
304 "sessionvars": sessionvars
270 })
305 })
271
306
272 try:
273 if not req.form.has_key('cmd'):
274 req.form['cmd'] = [self.t.cache['default']]
275
276 cmd = req.form['cmd'][0]
277
278 try:
279 if hasattr(protocol, cmd):
280 method = getattr(protocol, cmd)
281 else:
282 method = getattr(webcommands, cmd)
283 method(self, req)
284 except revlog.LookupError, err:
285 req.respond(404, self.t(
286 'error', error='revision not found: %s' % err.name))
287 except (hg.RepoError, revlog.RevlogError), inst:
288 req.respond('500 Internal Server Error',
289 self.t('error', error=str(inst)))
290 except ErrorResponse, inst:
291 req.respond(inst.code, self.t('error', error=inst.message))
292 except AttributeError:
293 req.respond(400,
294 self.t('error', error='No such method: ' + cmd))
295 finally:
296 self.t = None
297
298 def archivelist(self, nodeid):
307 def archivelist(self, nodeid):
299 allowed = self.configlist("web", "allow_archive")
308 allowed = self.configlist("web", "allow_archive")
300 for i, spec in self.archive_specs.iteritems():
309 for i, spec in self.archive_specs.iteritems():
General Comments 0
You need to be logged in to leave comments. Login now