D2805: hgweb: remove some use of wsgireq in hgwebdir
This revision was automatically updated to reflect the committed changes. Closed by commit rHGfc4e31297ffb: hgweb: remove some use of wsgireq in hgwebdir (authored by indygreg, committed by ). REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2805?vs=6877=6941 REVISION DETAIL https://phab.mercurial-scm.org/D2805 AFFECTED FILES mercurial/hgweb/hgwebdir_mod.py CHANGE DETAILS 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 @@ -200,16 +200,16 @@ wsgireq = requestmod.wsgirequest(env, respond) return self.run_wsgi(wsgireq) -def read_allowed(self, ui, wsgireq): +def readallowed(self, ui, req): """Check allow_read and deny_read config options of a repo's ui object to determine user permissions. By default, with neither option set (or both empty), allow all users to read the repo. There are two ways a user can be denied read access: (1) deny_read is not empty, and the user is unauthenticated or deny_read contains user (or *), and (2) allow_read is not empty and the user is not in allow_read. Return True if user is allowed to read the repo, else return False.""" -user = wsgireq.env.get('REMOTE_USER') +user = req.remoteuser deny_read = ui.configlist('web', 'deny_read', untrusted=True) if deny_read and (not user or ismember(ui, user, deny_read)): @@ -329,6 +329,7 @@ tmpl = None def makeindex(self, wsgireq, tmpl, subdir=""): +req = wsgireq.req def archivelist(ui, nodeid, url): allowed = ui.configlist("web", "allow_archive", untrusted=True) @@ -428,7 +429,7 @@ if u.configbool("web", "hidden", untrusted=True): continue -if not self.read_allowed(u, wsgireq): +if not self.readallowed(u, req): continue # update time with local timezone @@ -480,8 +481,8 @@ self.refresh() sortable = ["name", "description", "contact", "lastchange"] sortcolumn, descending = sortdefault -if 'sort' in wsgireq.req.qsparams: -sortcolumn = wsgireq.req.qsparams['sort'] +if 'sort' in req.qsparams: +sortcolumn = req.qsparams['sort'] descending = sortcolumn.startswith('-') if descending: sortcolumn = sortcolumn[1:] 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
D2805: hgweb: remove some use of wsgireq in hgwebdir
indygreg updated this revision to Diff 6877. indygreg edited the summary of this revision. REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D2805?vs=6866=6877 REVISION DETAIL https://phab.mercurial-scm.org/D2805 AFFECTED FILES mercurial/hgweb/hgwebdir_mod.py CHANGE DETAILS 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 @@ -200,16 +200,16 @@ wsgireq = requestmod.wsgirequest(env, respond) return self.run_wsgi(wsgireq) -def read_allowed(self, ui, wsgireq): +def readallowed(self, ui, req): """Check allow_read and deny_read config options of a repo's ui object to determine user permissions. By default, with neither option set (or both empty), allow all users to read the repo. There are two ways a user can be denied read access: (1) deny_read is not empty, and the user is unauthenticated or deny_read contains user (or *), and (2) allow_read is not empty and the user is not in allow_read. Return True if user is allowed to read the repo, else return False.""" -user = wsgireq.env.get('REMOTE_USER') +user = req.remoteuser deny_read = ui.configlist('web', 'deny_read', untrusted=True) if deny_read and (not user or ismember(ui, user, deny_read)): @@ -329,6 +329,7 @@ tmpl = None def makeindex(self, wsgireq, tmpl, subdir=""): +req = wsgireq.req def archivelist(ui, nodeid, url): allowed = ui.configlist("web", "allow_archive", untrusted=True) @@ -428,7 +429,7 @@ if u.configbool("web", "hidden", untrusted=True): continue -if not self.read_allowed(u, wsgireq): +if not self.readallowed(u, req): continue # update time with local timezone @@ -480,8 +481,8 @@ self.refresh() sortable = ["name", "description", "contact", "lastchange"] sortcolumn, descending = sortdefault -if 'sort' in wsgireq.req.qsparams: -sortcolumn = wsgireq.req.qsparams['sort'] +if 'sort' in req.qsparams: +sortcolumn = req.qsparams['sort'] descending = sortcolumn.startswith('-') if descending: sortcolumn = sortcolumn[1:] 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
D2805: hgweb: remove some use of wsgireq in hgwebdir
indygreg created this revision. Herald added a subscriber: mercurial-devel. Herald added a reviewer: hg-reviewers. REPOSITORY rHG Mercurial REVISION DETAIL https://phab.mercurial-scm.org/D2805 AFFECTED FILES mercurial/hgweb/hgwebdir_mod.py CHANGE DETAILS 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 @@ -200,16 +200,16 @@ wsgireq = requestmod.wsgirequest(env, respond) return self.run_wsgi(wsgireq) -def read_allowed(self, ui, wsgireq): +def read_allowed(self, ui, req): """Check allow_read and deny_read config options of a repo's ui object to determine user permissions. By default, with neither option set (or both empty), allow all users to read the repo. There are two ways a user can be denied read access: (1) deny_read is not empty, and the user is unauthenticated or deny_read contains user (or *), and (2) allow_read is not empty and the user is not in allow_read. Return True if user is allowed to read the repo, else return False.""" -user = wsgireq.env.get('REMOTE_USER') +user = req.remoteuser deny_read = ui.configlist('web', 'deny_read', untrusted=True) if deny_read and (not user or ismember(ui, user, deny_read)): @@ -329,6 +329,7 @@ tmpl = None def makeindex(self, wsgireq, tmpl, subdir=""): +req = wsgireq.req def archivelist(ui, nodeid, url): allowed = ui.configlist("web", "allow_archive", untrusted=True) @@ -428,7 +429,7 @@ if u.configbool("web", "hidden", untrusted=True): continue -if not self.read_allowed(u, wsgireq): +if not self.read_allowed(u, req): continue # update time with local timezone @@ -480,8 +481,8 @@ self.refresh() sortable = ["name", "description", "contact", "lastchange"] sortcolumn, descending = sortdefault -if 'sort' in wsgireq.req.qsparams: -sortcolumn = wsgireq.req.qsparams['sort'] +if 'sort' in req.qsparams: +sortcolumn = req.qsparams['sort'] descending = sortcolumn.startswith('-') if descending: sortcolumn = sortcolumn[1:] 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