Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgwebdir_mod.py @ 36862:1f7d9024674c
hgweb: make parsedrequest part of wsgirequest
This is kind of ugly. But an upcoming commit will teach parsedrequest
about the input stream. Because the input stream is global state and
can't be accessed without side-effects, we need to take actions to
ensure that multiple consumers don't read from it independently. The
easiest way to do this is for one object to hold a reference to both
items having access to the input stream so that when a copy is made,
we can remove the attribute from the other instance.
So we create our parsed request instance from the wsgirequest
constructor and hold a reference to it there. This is better than
our new type holding a reference to wsgirequest because all the
code for managing access will be temporary and we shouldn't pollute
parsedrequest with this ugly history.
Differential Revision: https://phab.mercurial-scm.org/D2770
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sat, 10 Mar 2018 10:56:10 -0800 |
parents | ec46415ed826 |
children | da4e2f87167d |
comparison
equal
deleted
inserted
replaced
36861:2cdf47e14c30 | 36862:1f7d9024674c |
---|---|
285 | 285 |
286 for virtualrepo in _virtualdirs(): | 286 for virtualrepo in _virtualdirs(): |
287 real = repos.get(virtualrepo) | 287 real = repos.get(virtualrepo) |
288 if real: | 288 if real: |
289 wsgireq.env['REPO_NAME'] = virtualrepo | 289 wsgireq.env['REPO_NAME'] = virtualrepo |
290 # We have to re-parse because of updated environment | |
291 # variable. | |
292 # TODO this is kind of hacky and we should have a better | |
293 # way of doing this than with REPO_NAME side-effects. | |
294 wsgireq.req = requestmod.parserequestfromenv(wsgireq.env) | |
290 try: | 295 try: |
291 # ensure caller gets private copy of ui | 296 # ensure caller gets private copy of ui |
292 repo = hg.repository(self.ui.copy(), real) | 297 repo = hg.repository(self.ui.copy(), real) |
293 return hgweb_mod.hgweb(repo).run_wsgi(wsgireq) | 298 return hgweb_mod.hgweb(repo).run_wsgi(wsgireq) |
294 except IOError as inst: | 299 except IOError as inst: |