# HG changeset patch # User Sune Foldager # Date 1258623153 -3600 # Node ID 38170eeed18c0dd3bafcde9306bca26d2bc789d5 # Parent 56af3f240a22f971827d9e68c2a23e5deb24c55e ui: add environ property to access os.environ or wsgirequest.environ The property returns os.environ by default, and is propagated by ui.copy. During hgweb processing, ui.environ is set to the proper WSGI-request environment, as contained in wsgirequest.environ. For CGI, this is the same as os.environ. The property is meant to be read-only, as with os.environ (generally). diff -r 56af3f240a22 -r 38170eeed18c mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Sun Nov 08 00:27:15 2009 +0100 +++ b/mercurial/hgweb/hgweb_mod.py Thu Nov 19 10:32:33 2009 +0100 @@ -54,7 +54,9 @@ return self.repo.ui.configlist(section, name, default, untrusted=untrusted) - def refresh(self): + def refresh(self, request=None): + if request: + self.ui.environ = request.environ mtime = get_mtime(self.repo.root) if mtime != self.mtime: self.mtime = mtime @@ -80,7 +82,7 @@ def run_wsgi(self, req): - self.refresh() + self.refresh(req) # work with CGI variables to create coherent structure # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME diff -r 56af3f240a22 -r 38170eeed18c mercurial/ui.py --- a/mercurial/ui.py Sun Nov 08 00:27:15 2009 +0100 +++ b/mercurial/ui.py Thu Nov 19 10:32:33 2009 +0100 @@ -29,8 +29,11 @@ self._ocfg = src._ocfg.copy() self._trustusers = src._trustusers.copy() self._trustgroups = src._trustgroups.copy() + self.environ = src.environ self.fixconfig() else: + # shared read-only environment + self.environ = os.environ # we always trust global config files for f in util.rcpath(): self.readconfig(f, trust=True)