hgweb: access to `rawenv` (or `$REQUEST_URI`) within a template
Norman Gray
gray at nxg.name
Sun Jan 23 13:11:17 UTC 2022
Greetings.
I have an hgweb server running behind nginx, which talks to it via
uwsgi. I want to get access to the REQUEST_URI uwsgi environment
variable within a template (ie, one of the .tmpl files), but can't work
out how to.
Looking at the code of request.py, I can see that the environment is
bundled up into a dict-valued rawenv attribute in a parsedrequest
object, and that the REQUEST_URI environment variable is in there. So
the information is... nearby, but I can't for the life of me work out
how to get at it from within a template.
I've tried {rawenv%REQUEST_URI} and {rawenv.REQUEST_URI}, and
(get(rawenv,'REQUEST_URI')}, so it's clear that my initial guess, that
the various relevant dictionaries are in scope to be looked up by the
Mercurial template language, is wrong. As you can see, though I've
looked at request.py, I haven't gone through it in enough detail to be
confident about how the information is moving about.
I'm conscious, of course, that there may be a horde of documentation I'm
simply missing, so I'm very happy to RTFM if I can find where the full
FM is located.
Why do I want this? Because of the way I've laid out the URLs here, with
some non-trivial (but not insane) URL rewriting, I've made things a bit
hard for myself: in the template, {url} doesn't expand to the actual URI
from the client point of view, but instead to the ârealâ location
after rewriting. It's the client-visible URL I want to manipulate in
the template.
I've looked at a few recent months in the list archive, and at entries
in the bugparade [1] (both open and a quick look through the closed
ones), but I haven't stumbled across any discussion of a similar issue.
I did ask a question on stackoverflow [2], but I don't think that's
currently a rich source of Hg help, unfortunately.
Thanks for any pointers,
Norman
[1]
https://bz.mercurial-scm.org/buglist.cgi?bug_status=__open__&content=hgweb&no_redirect=1&order=Importance&query_format=specific
[2]
https://stackoverflow.com/questions/70237641/hgweb-access-to-rawenv-or-request-uri-within-a-template
--
Norman Gray : https://nxg.me.uk
More information about the Mercurial-devel
mailing list