launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05502
[Merge] lp:~lifeless/python-oops-wsgi/bug-888866 into lp:python-oops-wsgi
Robert Collins has proposed merging lp:~lifeless/python-oops-wsgi/bug-888866 into lp:python-oops-wsgi.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~lifeless/python-oops-wsgi/bug-888866/+merge/82088
req_vars is now a dict in the core, for less friction. Migrate the oops-wsgi code and observe the pleasantness.
--
https://code.launchpad.net/~lifeless/python-oops-wsgi/bug-888866/+merge/82088
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~lifeless/python-oops-wsgi/bug-888866 into lp:python-oops-wsgi.
=== modified file 'NEWS'
--- NEWS 2011-11-13 21:57:57 +0000
+++ NEWS 2011-11-13 22:42:23 +0000
@@ -6,8 +6,14 @@
NEXT
----
+0.0.7
+-----
+
* Now licensed under LGPL-3. (Robert Collins)
+* The req_vars key is now generated as a dict, not a list.
+ (Robert Collins, #888866)
+
0.0.6
-----
=== modified file 'oops_wsgi/__init__.py'
--- oops_wsgi/__init__.py 2011-11-13 21:57:57 +0000
+++ oops_wsgi/__init__.py 2011-11-13 22:42:23 +0000
@@ -109,7 +109,7 @@
# established at this point, and setup.py will use a version of next-$(revno).
# If the releaselevel is 'final', then the tarball will be major.minor.micro.
# Otherwise it is major.minor.micro~$(revno).
-__version__ = (0, 0, 6, 'beta', 0)
+__version__ = (0, 0, 7, 'beta', 0)
__all__ = [
'install_hooks',
=== modified file 'oops_wsgi/hooks.py'
--- oops_wsgi/hooks.py 2011-11-13 21:57:57 +0000
+++ oops_wsgi/hooks.py 2011-11-13 22:42:23 +0000
@@ -47,18 +47,18 @@
"""
environ = context.get('wsgi_environ', {})
if 'req_vars' not in report:
- report['req_vars'] = []
+ report['req_vars'] = {}
req_vars = report['req_vars']
for key, value in sorted(environ.items()):
if (key in _wsgi_standard_env_keys or
key.startswith('HTTP_')):
- req_vars.append((key, value))
+ req_vars[key] = value
def hide_cookie(report, context):
"""If there is an HTTP_COOKIE entry in the report, hide its value.
- The entry is looked for either as a top level key or in the req_vars list.
+ The entry is looked for either as a top level key or in the req_vars dict.
The COOKIE header is often used to carry session tokens and thus permits
folk analyzing crash reports to log in as an arbitrary user (e.g. your
@@ -66,14 +66,8 @@
"""
if 'HTTP_COOKIE' in report:
report['HTTP_COOKIE'] = '<hidden>'
- if 'req_vars' not in report:
- return
- new_vars = []
- for key, value in report['req_vars']:
- if key == 'HTTP_COOKIE':
- value = '<hidden>'
- new_vars.append((key, value))
- report['req_vars'][:] = new_vars
+ if 'HTTP_COOKIE' in report.get('req_vars', {}):
+ report['req_vars']['HTTP_COOKIE'] = '<hidden>'
def install_hooks(config):
=== modified file 'oops_wsgi/tests/test_hooks.py'
--- oops_wsgi/tests/test_hooks.py 2011-11-13 21:57:57 +0000
+++ oops_wsgi/tests/test_hooks.py 2011-11-13 22:42:23 +0000
@@ -58,9 +58,9 @@
self.assertEqual({'HTTP_COOKIE': '<hidden>'}, report)
def test_hide_cookie_cookie_present_req_vars(self):
- report = {'req_vars': [('HTTP_COOKIE', 'foo')]}
+ report = {'req_vars': {'HTTP_COOKIE': 'foo'}}
hide_cookie(report, {})
- self.assertEqual({'req_vars': [('HTTP_COOKIE', '<hidden>')]}, report)
+ self.assertEqual({'req_vars': {'HTTP_COOKIE': '<hidden>'}}, report)
def test_copy_environ_copied_variables(self):
environ = {
@@ -81,7 +81,7 @@
context = dict(wsgi_environ=environ)
report = {}
copy_environ(report, context)
- expected_vars = sorted({
+ expected_vars = {
'REQUEST_METHOD': 'GET',
'SCRIPT_NAME': '',
'PATH_INFO': '/foo',
@@ -94,7 +94,7 @@
'HTTP_COOKIE': 'zaphod',
'wsgi.version': (1, 0),
'wsgi.url_scheme': 'https',
- }.items())
+ }
expected_report = {'req_vars': expected_vars}
self.assertEqual(expected_report, report)
=== modified file 'setup.py'
--- setup.py 2011-11-13 21:57:57 +0000
+++ setup.py 2011-11-13 22:42:23 +0000
@@ -23,7 +23,7 @@
os.path.join(os.path.dirname(__file__), 'README'), 'rb').read()
setup(name="oops_wsgi",
- version="0.0.6",
+ version="0.0.7",
description=\
"OOPS wsgi middleware.",
long_description=description,