Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/hgweb/hgweb_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 | f9078c6caeb6 |
children | a88d68dc3ee8 |
comparison
equal
deleted
inserted
replaced
36861:2cdf47e14c30 | 36862:1f7d9024674c |
---|---|
302 with profiling.profile(repo.ui, enabled=profile): | 302 with profiling.profile(repo.ui, enabled=profile): |
303 for r in self._runwsgi(wsgireq, repo): | 303 for r in self._runwsgi(wsgireq, repo): |
304 yield r | 304 yield r |
305 | 305 |
306 def _runwsgi(self, wsgireq, repo): | 306 def _runwsgi(self, wsgireq, repo): |
307 req = requestmod.parserequestfromenv(wsgireq.env) | 307 req = wsgireq.req |
308 rctx = requestcontext(self, repo) | 308 rctx = requestcontext(self, repo) |
309 | 309 |
310 # This state is global across all threads. | 310 # This state is global across all threads. |
311 encoding.encoding = rctx.config('web', 'encoding') | 311 encoding.encoding = rctx.config('web', 'encoding') |
312 rctx.repo.ui.environ = wsgireq.env | 312 rctx.repo.ui.environ = wsgireq.env |