Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix request path; #52

Merged
merged 4 commits into from
Oct 27, 2016
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion aiohttp_debugtoolbar/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
15 changes: 9 additions & 6 deletions aiohttp_debugtoolbar/panels/request_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ 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
if hasattr(request, 'session'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be request.get('aiohttp_session')

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you show me test example.

session = request.session
if not session.empty:
data.update({
'session': [(k, session[k]) for k in session],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use sorted keys: for k in sorted(session).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

})
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;
}