[PATCH 0 of 1] hgweb: add environ to template variables

FZiegler zarf at klacto.net
Tue Sep 21 08:36:36 CDT 2010


> I think this is a bad idea, because it exposes too much stuff to the
> templates.

The alternative then is to use [1] or [4], which only expose REMOTE_USER.
I'm only submitting this because interest was expressed on irc for
exposing things once and for all, rather than starting to make piecemeal
additions.

Personally I don't mind either way, as the environment does not contain
much else I'd want to use besides REMOTE_USER; but others may feel
differently. (For definiteness, see below what's in req and req.env at
this point [in my app].)

Francois

-----
[1] 'hgweb: add remoteuser to template variables'
http://selenic.com/pipermail/mercurial-devel/2010-September/024540.html
[4] 'hgweb: add environ.REMOTE_USER to template variables'
http://selenic.com/pipermail/mercurial-devel/2010-September/024627.html

>>> pprint(vars(req))
{'_start_response': <function start_response at 0x10bf922a8>,
 'env': {'DOCUMENT_ROOT': '/Library/WebServer/Documents',
         'HTTP_ACCEPT':
'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
         'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
         'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
         'HTTP_ACCEPT_LANGUAGE': 'en-us,en;q=0.5',
         'HTTP_CONNECTION': 'keep-alive',
         'HTTP_COOKIE':
'session="LcioYuUplpHiZ+gn4exnQSIt+5k=?username=Vmd1ZXN0CnAxCi4="',
         'HTTP_HOST': 'sandbox.klacto.net',
         'HTTP_KEEP_ALIVE': '300',
         'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X
10.6; en-US; rv:1.9.1.11) Gecko/20100701 Firefox/3.5.11',
         'PATH_INFO': '/Flask/MiniTwit/',
         'QUERY_STRING': '',
         'REMOTE_ADDR': '127.0.0.1',
         'REMOTE_PORT': '60853',
         'REMOTE_USER': u'guest',
         'REQUEST_METHOD': 'GET',
         'REQUEST_URI': '/mathg/Flask/MiniTwit/',
         'SCRIPT_NAME': '/mathg',
         'SERVER_ADDR': '127.0.0.1',
         'SERVER_ADMIN': 'you at example.com',
         'SERVER_NAME': 'sandbox.klacto.net',
         'SERVER_PORT': '80',
         'SERVER_PROTOCOL': 'HTTP/1.1',
         'SERVER_SOFTWARE': 'Apache/2.2.14 (Unix) mod_ssl/2.2.14
OpenSSL/0.9.8l DAV/2 Phusion_Passenger/2.2.15',
         '_': '_',
         'werkzeug.request': <AppRequest
'http://sandbox.klacto.net/mathg/Flask/MiniTwit/' [GET]>,
         'wsgi.errors': <open file '<stderr>', mode 'w' at 0x1001c5140>,
         'wsgi.input': <socket._fileobject object at 0x10b8be140>,
         'wsgi.multiprocess': True,
         'wsgi.multithread': False,
         'wsgi.run_once': True,
         'wsgi.url_scheme': 'http',
         'wsgi.version': (1, 0)},
 'err': <open file '<stderr>', mode 'w' at 0x1001c5140>,
 'form': {},
 'headers': [],
 'inp': <socket._fileobject object at 0x10b8be140>,
 'multiprocess': True,
 'run_once': True,
 'server_write': None,
 'threaded': False}




More information about the Mercurial-devel mailing list