From f0c077b3ce45377da893a50be8c066e618a2163b Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 26 Oct 2016 19:44:46 +0300 Subject: [PATCH 1/4] fix request path; --- aiohttp_debugtoolbar/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiohttp_debugtoolbar/main.py b/aiohttp_debugtoolbar/main.py index e02ee152..8d6f227b 100644 --- a/aiohttp_debugtoolbar/main.py +++ b/aiohttp_debugtoolbar/main.py @@ -89,7 +89,7 @@ def setup(app, **kw): app.router.add_route('GET', path_prefix + '/sse', views.sse, name='debugtoolbar.sse') - app.router.add_route('GET', path_prefix + '/_debugtoolbar/{request_id}', + app.router.add_route('GET', path_prefix + '/{request_id}', views.request_view, name='debugtoolbar.request') app.router.add_route('GET', path_prefix, views.request_view, name='debugtoolbar.main') From 5237eb77d5bde80e106810042c3828f181913cd6 Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 26 Oct 2016 21:35:22 +0300 Subject: [PATCH 2/4] Add session to RequestVars panel; Improve templates(headers, request_vars) and stylesheet; --- aiohttp_debugtoolbar/panels/request_vars.py | 15 ++++++++----- .../panels/templates/headers.jinja2 | 12 ++++++++-- .../panels/templates/request_vars.jinja2 | 22 ++++++++++++++----- aiohttp_debugtoolbar/static/css/debugger.css | 5 +++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/aiohttp_debugtoolbar/panels/request_vars.py b/aiohttp_debugtoolbar/panels/request_vars.py index 2e2acadc..78bfa51f 100644 --- a/aiohttp_debugtoolbar/panels/request_vars.py +++ b/aiohttp_debugtoolbar/panels/request_vars.py @@ -1,4 +1,5 @@ import asyncio +from aiohttp_session import get_session from pprint import saferepr from .base import DebugPanel @@ -32,10 +33,12 @@ def process_response(self, response): 'cookies': [(k, request.cookies.get(k)) for k in request.cookies], 'attrs': [(k, v) for k, v in request.items()], }) - # TODO: think about adding aiohttp_sessions support as separate table - # and maybe aiohttp_security - # if hasattr(request, 'session'): - # data.update({ - # 'session': dictrepr(request.session), - # }) + # TODO: think about aiohttp_security + + # session to separate table + session = yield from get_session(request) + if not session.empty: + data.update({ + 'session': [(k, session[k]) for k in session], + }) diff --git a/aiohttp_debugtoolbar/panels/templates/headers.jinja2 b/aiohttp_debugtoolbar/panels/templates/headers.jinja2 index e8a427ff..9e2ce3ce 100644 --- a/aiohttp_debugtoolbar/panels/templates/headers.jinja2 +++ b/aiohttp_debugtoolbar/panels/templates/headers.jinja2 @@ -1,5 +1,9 @@

Request Headers

+ + + + @@ -10,7 +14,7 @@ {% for key, value in request_headers %} - + {% endfor %} @@ -18,6 +22,10 @@

Response Headers

Key
{{ key }}{{ value }}{{ value }}
+ + + + @@ -28,7 +36,7 @@ {% for key, value in response_headers %} - + {% endfor %} diff --git a/aiohttp_debugtoolbar/panels/templates/request_vars.jinja2 b/aiohttp_debugtoolbar/panels/templates/request_vars.jinja2 index d24f5f9b..bee23d17 100644 --- a/aiohttp_debugtoolbar/panels/templates/request_vars.jinja2 +++ b/aiohttp_debugtoolbar/panels/templates/request_vars.jinja2 @@ -15,7 +15,7 @@ {% for key, value in cookies %} - + {% endfor %} @@ -41,7 +41,7 @@ {% for key, value in session %} - + {% endfor %} @@ -53,6 +53,10 @@

GET Variables

{% if get %}
Key
{{ key }}{{ value }}{{ value }}
{{ key }}{{ value }}{{ value }}
{{ key }}{{ value }}{{ value }}
+ + + + @@ -63,7 +67,7 @@ {% for key, value in get %} - + {% endfor %} @@ -75,6 +79,10 @@

POST Variables

{% if post %}
Variable
{{ key }}{{ ', '.join(value) }}{{ ', '.join(value) }}
+ + + + @@ -85,7 +93,7 @@ {% for key, value in post %} - + {% endfor %} @@ -97,6 +105,10 @@

Request attributes

{% if attrs %}
Variable
{{ key }}{{ value }}{{ value }}
+ + + + @@ -107,7 +119,7 @@ {% for key, value in attrs %} - + {% endfor %} diff --git a/aiohttp_debugtoolbar/static/css/debugger.css b/aiohttp_debugtoolbar/static/css/debugger.css index e19e3dac..4b33dc4e 100644 --- a/aiohttp_debugtoolbar/static/css/debugger.css +++ b/aiohttp_debugtoolbar/static/css/debugger.css @@ -105,3 +105,8 @@ div.sourceview span.current { width: 100%; background-color: #ddd; } + +td.value { + word-break: break-all; + word-wrap: break-word; +} From b65ed78957d9b8f68bc68092034e6bfb6a4e432f Mon Sep 17 00:00:00 2001 From: Alexander Date: Wed, 26 Oct 2016 21:50:37 +0300 Subject: [PATCH 3/4] add check attr in request; remove aiohttp_session module; --- aiohttp_debugtoolbar/panels/request_vars.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/aiohttp_debugtoolbar/panels/request_vars.py b/aiohttp_debugtoolbar/panels/request_vars.py index 78bfa51f..18bec327 100644 --- a/aiohttp_debugtoolbar/panels/request_vars.py +++ b/aiohttp_debugtoolbar/panels/request_vars.py @@ -1,5 +1,4 @@ import asyncio -from aiohttp_session import get_session from pprint import saferepr from .base import DebugPanel @@ -37,8 +36,9 @@ def process_response(self, response): # TODO: think about aiohttp_security # session to separate table - session = yield from get_session(request) - if not session.empty: - data.update({ - 'session': [(k, session[k]) for k in session], - }) + if hasattr(request, 'session'): + session = request.session + if not session.empty: + data.update({ + 'session': [(k, session[k]) for k in session], + }) From 4214e3398d10e97f6bd180d94a188a444fa33936 Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 27 Oct 2016 17:11:42 +0300 Subject: [PATCH 4/4] add sorted to dicts; add getall() to POST; fix session get; --- aiohttp_debugtoolbar/panels/request_vars.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/aiohttp_debugtoolbar/panels/request_vars.py b/aiohttp_debugtoolbar/panels/request_vars.py index 18bec327..4f183d4c 100644 --- a/aiohttp_debugtoolbar/panels/request_vars.py +++ b/aiohttp_debugtoolbar/panels/request_vars.py @@ -27,18 +27,18 @@ def process_response(self, response): request = self.request yield from request.post() data.update({ - 'get': [(k, request.GET.getall(k)) for k in request.GET], - 'post': [(k, saferepr(v)) for k, v in request.POST.items()], - 'cookies': [(k, request.cookies.get(k)) for k in request.cookies], - 'attrs': [(k, v) for k, v in request.items()], + 'get': [(k, request.GET.getall(k)) for k in sorted(request.GET)], + 'post': [(k, saferepr(request.POST.getall(k))) + for k in sorted(request.POST)], + 'cookies': [(k, v) for k, v in sorted(request.cookies.items())], + 'attrs': [(k, v) for k, v in sorted(request.items())], }) # TODO: think about aiohttp_security # session to separate table - if hasattr(request, 'session'): - session = request.session - if not session.empty: - data.update({ - 'session': [(k, session[k]) for k in session], - }) + session = request.get('aiohttp_session') + if session and not session.empty: + data.update({ + 'session': [(k, v) for k, v in sorted(session.items())], + })
Attribute
{{ key }}{{ value }}{{ value }}