diff options
Diffstat (limited to 'debug_toolbar')
| -rw-r--r-- | debug_toolbar/panels/http_vars.py | 21 | ||||
| -rw-r--r-- | debug_toolbar/panels/request_vars.py | 23 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/panels/http_vars.html | 42 | ||||
| -rw-r--r-- | debug_toolbar/templates/debug_toolbar/panels/request_vars.html | 92 | 
4 files changed, 115 insertions, 63 deletions
diff --git a/debug_toolbar/panels/http_vars.py b/debug_toolbar/panels/http_vars.py deleted file mode 100644 index 98d5fc8..0000000 --- a/debug_toolbar/panels/http_vars.py +++ /dev/null @@ -1,21 +0,0 @@ -from django.template.loader import render_to_string -from debug_toolbar.panels import DebugPanel - -class HttpVarsDebugPanel(DebugPanel): -    """ -    A panel to display HTTP variables (POST/GET). -    """ -    name = 'HttpVars' - -    def title(self): -        return 'POST/GET' - -    def url(self): -        return '' - -    def content(self): -        context = { -            'get': [(k, self.request.GET.getlist(k)) for k in self.request.GET.iterkeys()], -            'post': [(k, self.request.POST.getlist(k)) for k in self.request.POST.iterkeys()] -        } -        return render_to_string('debug_toolbar/panels/http_vars.html', context)
\ No newline at end of file diff --git a/debug_toolbar/panels/request_vars.py b/debug_toolbar/panels/request_vars.py new file mode 100644 index 0000000..9f1a30d --- /dev/null +++ b/debug_toolbar/panels/request_vars.py @@ -0,0 +1,23 @@ +from django.template.loader import render_to_string +from debug_toolbar.panels import DebugPanel + +class RequestVarsDebugPanel(DebugPanel): +    """ +    A panel to display request variables (POST/GET, session, cookies). +    """ +    name = 'RequestVars' + +    def title(self): +        return 'Request Vars' + +    def url(self): +        return '' + +    def content(self): +        context = { +            'get': [(k, self.request.GET.getlist(k)) for k in self.request.GET.iterkeys()], +            'post': [(k, self.request.POST.getlist(k)) for k in self.request.POST.iterkeys()], +            'session': [(k, self.request.session.get(k)) for k in self.request.session.iterkeys()], +            'cookies': [(k, self.request.COOKIES.get(k)) for k in self.request.COOKIES.iterkeys()], +        } +        return render_to_string('debug_toolbar/panels/request_vars.html', context)
\ No newline at end of file diff --git a/debug_toolbar/templates/debug_toolbar/panels/http_vars.html b/debug_toolbar/templates/debug_toolbar/panels/http_vars.html deleted file mode 100644 index 8891f30..0000000 --- a/debug_toolbar/templates/debug_toolbar/panels/http_vars.html +++ /dev/null @@ -1,42 +0,0 @@ -<h3>GET Variables</h3> -{% if get %} -	<table> -		<thead> -			<tr> -				<th>Key</th> -				<th>Value</th> -			</tr> -		</thead> -		<tbody> -			{% for key, value in get %} -				<tr class="{% cycle 'row1' 'row2' %}"> -					<td>{{ key|escape }}</td> -					<td>{{ value|join:", "|escape }}</td> -				</tr> -			{% endfor %} -		</tbody> -	</table> -{% else %} -	<p>None</p> -{% endif %} -<h3>POST Variables</h3> -{% if post %} -	<table> -		<thead> -			<tr> -				<th>Key</th> -				<th>Value</th> -			</tr> -		</thead> -		<tbody> -			{% for key, value in post %} -				<tr class="{% cycle 'row1' 'row2' %}"> -					<td>{{ key|escape }}</td> -					<td>{{ value|join:", "|escape }}</td> -				</tr> -			{% endfor %} -		</tbody> -	</table> -{% else %} -	<p>None</p> -{% endif %}
\ No newline at end of file diff --git a/debug_toolbar/templates/debug_toolbar/panels/request_vars.html b/debug_toolbar/templates/debug_toolbar/panels/request_vars.html new file mode 100644 index 0000000..fdb0a74 --- /dev/null +++ b/debug_toolbar/templates/debug_toolbar/panels/request_vars.html @@ -0,0 +1,92 @@ +<h3>COOKIES Variables</h3> +{% if cookies %} +	<table> +		<colgroup> +			<col style="width:20%"/> +			<col/> +		</colgroup> +		<thead> +			<tr> +				<th>Key</th> +				<th>Value</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in cookies %} +				<tr class="{% cycle 'row1' 'row2' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|escape }}</td> +				</tr> +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>None</p> +{% endif %} +<h3>SESSION Variables</h3> +{% if session %} +	<table> +		<colgroup> +			<col style="width:20%"/> +			<col/> +		</colgroup> +		<thead> +			<tr> +				<th>Key</th> +				<th>Value</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in session %} +				<tr class="{% cycle 'row1' 'row2' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|escape }}</td> +				</tr> +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>None</p> +{% endif %} +<h3>GET Variables</h3> +{% if get %} +	<table> +		<thead> +			<tr> +				<th>Key</th> +				<th>Value</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in get %} +				<tr class="{% cycle 'row1' 'row2' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|join:", "|escape }}</td> +				</tr> +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>None</p> +{% endif %} +<h3>POST Variables</h3> +{% if post %} +	<table> +		<thead> +			<tr> +				<th>Key</th> +				<th>Value</th> +			</tr> +		</thead> +		<tbody> +			{% for key, value in post %} +				<tr class="{% cycle 'row1' 'row2' %}"> +					<td>{{ key|escape }}</td> +					<td>{{ value|join:", "|escape }}</td> +				</tr> +			{% endfor %} +		</tbody> +	</table> +{% else %} +	<p>None</p> +{% endif %}  | 
