comparison mercurial/hgweb/hgweb_mod.py @ 9887:38170eeed18c

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).
author Sune Foldager <cryo@cyanite.org>
date Thu, 19 Nov 2009 10:32:33 +0100
parents d3dbdca92458
children 510122bb3c7f
comparison
equal deleted inserted replaced
9886:56af3f240a22 9887:38170eeed18c
52 52
53 def configlist(self, section, name, default=None, untrusted=True): 53 def configlist(self, section, name, default=None, untrusted=True):
54 return self.repo.ui.configlist(section, name, default, 54 return self.repo.ui.configlist(section, name, default,
55 untrusted=untrusted) 55 untrusted=untrusted)
56 56
57 def refresh(self): 57 def refresh(self, request=None):
58 if request:
59 self.ui.environ = request.environ
58 mtime = get_mtime(self.repo.root) 60 mtime = get_mtime(self.repo.root)
59 if mtime != self.mtime: 61 if mtime != self.mtime:
60 self.mtime = mtime 62 self.mtime = mtime
61 self.repo = hg.repository(self.repo.ui, self.repo.root) 63 self.repo = hg.repository(self.repo.ui, self.repo.root)
62 self.maxchanges = int(self.config("web", "maxchanges", 10)) 64 self.maxchanges = int(self.config("web", "maxchanges", 10))
78 req = wsgirequest(env, respond) 80 req = wsgirequest(env, respond)
79 return self.run_wsgi(req) 81 return self.run_wsgi(req)
80 82
81 def run_wsgi(self, req): 83 def run_wsgi(self, req):
82 84
83 self.refresh() 85 self.refresh(req)
84 86
85 # work with CGI variables to create coherent structure 87 # work with CGI variables to create coherent structure
86 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME 88 # use SCRIPT_NAME, PATH_INFO and QUERY_STRING as well as our REPO_NAME
87 89
88 req.url = req.env['SCRIPT_NAME'] 90 req.url = req.env['SCRIPT_NAME']