comparison mercurial/hgweb/hgweb_mod.py @ 36911:f0a851542a05

hgweb: remove wsgirequest (API) Good riddance. .. api:: The old ``wsgirequest`` class for handling everything WSGI in hgweb has been replaced by separate request and response types. Various high-level functions in the hgweb WSGI applications now receive these new types as arguments instead of the old ``wsgirequest`` type. Differential Revision: https://phab.mercurial-scm.org/D2832
author Gregory Szorc <gregory.szorc@gmail.com>
date Sun, 11 Mar 2018 16:29:54 -0700
parents 84110a1d0f7d
children 6ff6e1d6b5b8
comparison
equal deleted inserted replaced
36910:98487ad0cf8b 36911:f0a851542a05
288 def __call__(self, env, respond): 288 def __call__(self, env, respond):
289 """Run the WSGI application. 289 """Run the WSGI application.
290 290
291 This may be called by multiple threads. 291 This may be called by multiple threads.
292 """ 292 """
293 req = requestmod.wsgirequest(env, respond) 293 req = requestmod.parserequestfromenv(env)
294 return self.run_wsgi(req) 294 res = requestmod.wsgiresponse(req, respond)
295 295
296 def run_wsgi(self, wsgireq): 296 return self.run_wsgi(req, res)
297
298 def run_wsgi(self, req, res):
297 """Internal method to run the WSGI application. 299 """Internal method to run the WSGI application.
298 300
299 This is typically only called by Mercurial. External consumers 301 This is typically only called by Mercurial. External consumers
300 should be using instances of this class as the WSGI application. 302 should be using instances of this class as the WSGI application.
301 """ 303 """
302 with self._obtainrepo() as repo: 304 with self._obtainrepo() as repo:
303 profile = repo.ui.configbool('profiling', 'enabled') 305 profile = repo.ui.configbool('profiling', 'enabled')
304 with profiling.profile(repo.ui, enabled=profile): 306 with profiling.profile(repo.ui, enabled=profile):
305 for r in self._runwsgi(wsgireq, repo): 307 for r in self._runwsgi(req, res, repo):
306 yield r 308 yield r
307 309
308 def _runwsgi(self, wsgireq, repo): 310 def _runwsgi(self, req, res, repo):
309 req = wsgireq.req
310 res = wsgireq.res
311 rctx = requestcontext(self, repo, req, res) 311 rctx = requestcontext(self, repo, req, res)
312 312
313 # This state is global across all threads. 313 # This state is global across all threads.
314 encoding.encoding = rctx.config('web', 'encoding') 314 encoding.encoding = rctx.config('web', 'encoding')
315 rctx.repo.ui.environ = req.rawenv 315 rctx.repo.ui.environ = req.rawenv