comparison mercurial/hgweb/hgwebdir_mod.py @ 36865:3d60a22e27f5

hgweb: perform all parameter lookup via qsparams I think I managed to update all call sites using wsgirequest.form to use parsedrequest.qsparams. Since behavior of qsparams is to retrieve last value, behavior will change if a parameter was specified multiple times. But I think this is acceptable. I'm not a fan of the `req.req.qsparams` pattern. And some of the modified code could be written better. But I was aiming for a straight port with this change. Cleanup can come later. Differential Revision: https://phab.mercurial-scm.org/D2781
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 10 Mar 2018 12:36:36 -0800
parents 1a1972b1a1ff
children 98baf8dea553
comparison
equal deleted inserted replaced
36864:4e06e8336634 36865:3d60a22e27f5
227 with profiling.profile(self.ui, enabled=profile): 227 with profiling.profile(self.ui, enabled=profile):
228 for r in self._runwsgi(wsgireq): 228 for r in self._runwsgi(wsgireq):
229 yield r 229 yield r
230 230
231 def _runwsgi(self, wsgireq): 231 def _runwsgi(self, wsgireq):
232 req = wsgireq.req
233
232 try: 234 try:
233 self.refresh() 235 self.refresh()
234 236
235 csp, nonce = cspvalues(self.ui) 237 csp, nonce = cspvalues(self.ui)
236 if csp: 238 if csp:
240 tmpl = self.templater(wsgireq, nonce) 242 tmpl = self.templater(wsgireq, nonce)
241 ctype = tmpl('mimetype', encoding=encoding.encoding) 243 ctype = tmpl('mimetype', encoding=encoding.encoding)
242 ctype = templater.stringify(ctype) 244 ctype = templater.stringify(ctype)
243 245
244 # a static file 246 # a static file
245 if virtual.startswith('static/') or 'static' in wsgireq.form: 247 if virtual.startswith('static/') or 'static' in req.qsparams:
246 if virtual.startswith('static/'): 248 if virtual.startswith('static/'):
247 fname = virtual[7:] 249 fname = virtual[7:]
248 else: 250 else:
249 fname = wsgireq.form['static'][0] 251 fname = req.qsparams['static']
250 static = self.ui.config("web", "static", None, 252 static = self.ui.config("web", "static", None,
251 untrusted=False) 253 untrusted=False)
252 if not static: 254 if not static:
253 tp = self.templatepath or templater.templatepaths() 255 tp = self.templatepath or templater.templatepaths()
254 if isinstance(tp, str): 256 if isinstance(tp, str):
469 yield row 471 yield row
470 472
471 self.refresh() 473 self.refresh()
472 sortable = ["name", "description", "contact", "lastchange"] 474 sortable = ["name", "description", "contact", "lastchange"]
473 sortcolumn, descending = sortdefault 475 sortcolumn, descending = sortdefault
474 if 'sort' in wsgireq.form: 476 if 'sort' in wsgireq.req.qsparams:
475 sortcolumn = wsgireq.form['sort'][0] 477 sortcolum = wsgireq.req.qsparams['sort']
476 descending = sortcolumn.startswith('-') 478 descending = sortcolumn.startswith('-')
477 if descending: 479 if descending:
478 sortcolumn = sortcolumn[1:] 480 sortcolumn = sortcolumn[1:]
479 if sortcolumn not in sortable: 481 if sortcolumn not in sortable:
480 sortcolumn = "" 482 sortcolumn = ""