Skip to content

Commit

Permalink
Add session to RequestVars panel; Improve templates(headers, request_…
Browse files Browse the repository at this point in the history
…vars) and stylesheet;
  • Loading branch information
iamraa committed Oct 26, 2016
1 parent f0c077b commit 5237eb7
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 13 deletions.
15 changes: 9 additions & 6 deletions aiohttp_debugtoolbar/panels/request_vars.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import asyncio
from aiohttp_session import get_session
from pprint import saferepr

from .base import DebugPanel
Expand Down Expand Up @@ -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],
})
12 changes: 10 additions & 2 deletions aiohttp_debugtoolbar/panels/templates/headers.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<h4>Request Headers</h4>
<table class="table table-striped">
<colgroup>
<col style="width:20%"/>
<col/>
</colgroup>
<thead>
<tr>
<th>Key</th>
Expand All @@ -10,14 +14,18 @@
{% for key, value in request_headers %}
<tr class="{{ loop.index%2 and 'pDebugEven' or 'pDebugOdd' }}">
<td>{{ key }}</td>
<td>{{ value }}</td>
<td class="value">{{ value }}</td>
</tr>
{% endfor %}
</tbody>
</table>

<h4>Response Headers</h4>
<table class="table table-striped">
<colgroup>
<col style="width:20%"/>
<col/>
</colgroup>
<thead>
<tr>
<th>Key</th>
Expand All @@ -28,7 +36,7 @@
{% for key, value in response_headers %}
<tr class="{{ loop.index%2 and 'pDebugEven' or 'pDebugOdd' }}">
<td>{{ key }}</td>
<td>{{ value }}</td>
<td class="value">{{ value }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
22 changes: 17 additions & 5 deletions aiohttp_debugtoolbar/panels/templates/request_vars.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
{% for key, value in cookies %}
<tr class="{{ loop.index%2 and 'pDebugEven' or 'pDebugOdd' }}">
<td>{{ key }}</td>
<td>{{ value }}</td>
<td class="value">{{ value }}</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -41,7 +41,7 @@
{% for key, value in session %}
<tr class="{{ loop.index%2 and 'pDebugEven' or 'pDebugOdd' }}">
<td>{{ key }}</td>
<td>{{ value }}</td>
<td class="value">{{ value }}</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -53,6 +53,10 @@
<h4>GET Variables</h4>
{% if get %}
<table class="table table-striped">
<colgroup>
<col style="width:20%"/>
<col/>
</colgroup>
<thead>
<tr>
<th>Variable</th>
Expand All @@ -63,7 +67,7 @@
{% for key, value in get %}
<tr class="{{ loop.index%2 and 'pDebugEven' or 'pDebugOdd' }}">
<td>{{ key }}</td>
<td>{{ ', '.join(value) }}</td>
<td class="value">{{ ', '.join(value) }}</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -75,6 +79,10 @@
<h4>POST Variables</h4>
{% if post %}
<table class="table table-striped">
<colgroup>
<col style="width:20%"/>
<col/>
</colgroup>
<thead>
<tr>
<th>Variable</th>
Expand All @@ -85,7 +93,7 @@
{% for key, value in post %}
<tr class="{{ loop.index%2 and 'pDebugEven' or 'pDebugOdd' }}">
<td>{{ key }}</td>
<td>{{ value }}</td>
<td class="value">{{ value }}</td>
</tr>
{% endfor %}
</tbody>
Expand All @@ -97,6 +105,10 @@
<h4>Request attributes</h4>
{% if attrs %}
<table class="table table-striped">
<colgroup>
<col style="width:20%"/>
<col/>
</colgroup>
<thead>
<tr>
<th>Attribute</th>
Expand All @@ -107,7 +119,7 @@
{% for key, value in attrs %}
<tr class="{{ loop.index%2 and 'pDebugEven' or 'pDebugOdd' }}">
<td>{{ key }}</td>
<td>{{ value }}</td>
<td class="value">{{ value }}</td>
</tr>
{% endfor %}
</tbody>
Expand Down
5 changes: 5 additions & 0 deletions aiohttp_debugtoolbar/static/css/debugger.css
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,8 @@ div.sourceview span.current {
width: 100%;
background-color: #ddd;
}

td.value {
word-break: break-all;
word-wrap: break-word;
}

0 comments on commit 5237eb7

Please sign in to comment.