D2770: hgweb: make parsedrequest part of wsgirequest
This revision was automatically updated to reflect the committed changes. Closed by commit rHG1f7d9024674c: hgweb: make parsedrequest part of wsgirequest (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2770?vs=6832=6908 REVISION DETAIL https://phab.mercurial-scm.org/D2770 AFFECTED FILES mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py mercurial/hgweb/request.py CHANGE DETAILS diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py --- a/mercurial/hgweb/request.py +++ b/mercurial/hgweb/request.py @@ -254,6 +254,8 @@ self.server_write = None self.headers = [] +self.req = parserequestfromenv(wsgienv) + def respond(self, status, type, filename=None, body=None): if not isinstance(type, str): type = pycompat.sysstr(type) diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -287,6 +287,11 @@ real = repos.get(virtualrepo) if real: wsgireq.env['REPO_NAME'] = virtualrepo +# We have to re-parse because of updated environment +# variable. +# TODO this is kind of hacky and we should have a better +# way of doing this than with REPO_NAME side-effects. +wsgireq.req = requestmod.parserequestfromenv(wsgireq.env) try: # ensure caller gets private copy of ui repo = hg.repository(self.ui.copy(), real) diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -304,7 +304,7 @@ yield r def _runwsgi(self, wsgireq, repo): -req = requestmod.parserequestfromenv(wsgireq.env) +req = wsgireq.req rctx = requestcontext(self, repo) # This state is global across all threads. To: indygreg, #hg-reviewers, durin42 Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2770: hgweb: make parsedrequest part of wsgirequest
indygreg updated this revision to Diff 6832. indygreg edited the summary of this revision. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2770?vs=6814=6832 REVISION DETAIL https://phab.mercurial-scm.org/D2770 AFFECTED FILES mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py mercurial/hgweb/request.py CHANGE DETAILS diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py --- a/mercurial/hgweb/request.py +++ b/mercurial/hgweb/request.py @@ -254,6 +254,8 @@ self.server_write = None self.headers = [] +self.req = parserequestfromenv(wsgienv) + def respond(self, status, type, filename=None, body=None): if not isinstance(type, str): type = pycompat.sysstr(type) diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -287,6 +287,11 @@ real = repos.get(virtualrepo) if real: wsgireq.env['REPO_NAME'] = virtualrepo +# We have to re-parse because of updated environment +# variable. +# TODO this is kind of hacky and we should have a better +# way of doing this than with REPO_NAME side-effects. +wsgireq.req = requestmod.parserequestfromenv(wsgireq.env) try: # ensure caller gets private copy of ui repo = hg.repository(self.ui.copy(), real) diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -304,7 +304,7 @@ yield r def _runwsgi(self, wsgireq, repo): -req = requestmod.parserequestfromenv(wsgireq.env) +req = wsgireq.req rctx = requestcontext(self, repo) # This state is global across all threads. To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
D2770: hgweb: make parsedrequest part of wsgirequest
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REVISION SUMMARY This is kind of ugly. But upcoming commits will teach our parsedrequest instances about how to read from the input stream and how to parse form variables which might be specified on 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 things so it can ensure (via attribute nuking) that consumers only touch one object or the other. 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. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2770 AFFECTED FILES mercurial/hgweb/hgweb_mod.py mercurial/hgweb/hgwebdir_mod.py mercurial/hgweb/request.py CHANGE DETAILS diff --git a/mercurial/hgweb/request.py b/mercurial/hgweb/request.py --- a/mercurial/hgweb/request.py +++ b/mercurial/hgweb/request.py @@ -254,6 +254,8 @@ self.server_write = None self.headers = [] +self.req = parserequestfromenv(wsgienv) + def respond(self, status, type, filename=None, body=None): if not isinstance(type, str): type = pycompat.sysstr(type) diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py +++ b/mercurial/hgweb/hgwebdir_mod.py @@ -229,7 +229,7 @@ yield r def _runwsgi(self, wsgireq): -req = requestmod.parserequestfromenv(wsgireq.env) +req = wsgireq.req try: self.refresh() @@ -289,6 +289,11 @@ real = repos.get(virtualrepo) if real: wsgireq.env['REPO_NAME'] = virtualrepo +# We have to re-parse because of updated environment +# variable. +# TODO this is kind of hacky and we should have a better +# way of doing this than with REPO_NAME side-effects. +wsgireq.req = requestmod.parserequestfromenv(wsgireq.env) try: # ensure caller gets private copy of ui repo = hg.repository(self.ui.copy(), real) diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py +++ b/mercurial/hgweb/hgweb_mod.py @@ -304,7 +304,7 @@ yield r def _runwsgi(self, wsgireq, repo): -req = requestmod.parserequestfromenv(wsgireq.env) +req = wsgireq.req rctx = requestcontext(self, repo) # This state is global across all threads. To: indygreg, #hg-reviewers Cc: mercurial-devel ___ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel