[PATCH 4 of 4] Arrange for old copies of CGI scripts to still
work
Eric Hopper
hopper at omnifarious.org
Fri Jun 30 11:54:36 CDT 2006
On Fri, Jun 30, 2006 at 12:45:38PM -0300, Alexis S. L. Carvalho wrote:
> Thus spake Eric Hopper:
> > diff -r d5a3cc6520d5 -r b8ccf6386db7 mercurial/hgweb/hgweb_mod.py
> > --- a/mercurial/hgweb/hgweb_mod.py Thu Jun 29 18:34:26 2006 -0700
> > +++ b/mercurial/hgweb/hgweb_mod.py Thu Jun 29 19:06:18 2006 -0700
> > @@ -650,7 +650,16 @@ class hgweb(object):
> > raise Exception("suspicious path")
> > return p
> >
> > - def run(self, req):
> > + def run(self):
> > + if os.environ['GATEWAY_INTERFACE'][0:6] != "CGI/1.":
>
> maybe os.environ.get('GATEWAY_INTERFACE', '').startswith('CGI/1.') ?
That is possibly a little better. It makes sure the exception raised
always clearly states the real error. I tend not to like special
purpose functions like 'startswith' though. But I suppose it's a bit
clearer.
> > + raise RuntimeError("This function is only intended to be called while running as a CGI script.")
> > + import mercurial.hgweb.wsgicgi as wsgicgi
> > + from request import wsgiapplication
> > + def make_web_app():
> > + return self.__class__(self.repo, self.reponame)
> > + wsgicgi.launch(wsgiapplication(make_web_app))
> > +
>
> Isn't it possible for make_web_app to just return self?
>
> (same comments for hgwebdir_mod.py)
Why yes, yes it is. *slaps forehead*
*sigh*,
--
"It does me no injury for my neighbor to say there are twenty gods or no God.
It neither picks my pocket nor breaks my leg." --- Thomas Jefferson
"Go to Heaven for the climate, Hell for the company." -- Mark Twain
-- Eric Hopper (http://www.omnifarious.org/~hopper) --
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.selenic.com/pipermail/mercurial/attachments/20060630/1bf54280/attachment.pgp
More information about the Mercurial
mailing list