Giter Site home page Giter Site logo

pyramid_debugtoolbar's Introduction

pyramid_debugtoolbar

pyramid_debugtoolbar provides a debug toolbar useful while you're developing your Pyramid application.

Note that pyramid_debugtoolbar is a blatant rip-off of Michael van Tellingen's flask-debugtoolbar (which itself was derived from Rob Hudson's django-debugtoolbar). It also includes a lightly sanded down version of the Werkzeug debugger code by Armin Ronacher and team.

Documentation

The documentation of the current stable release of pyramid_debugtoolbar is available at https://docs.pylonsproject.org/projects/pyramid-debugtoolbar/en/latest/.

Demonstration

For a demonstration:

  • Clone the pyramid_debugtoolbar trunk.

    $ git clone https://github.com/Pylons/pyramid_debugtoolbar.git
  • Create a virtual environment in the workspace.

    $ cd pyramid_debugtoolbar
    $ python3 -m venv env
  • Install the pyramid_debugtoolbar trunk into the virtualenv.

    $ env/bin/pip install -e .
  • Install the pyramid_debugtoolbar/demo package into the virtualenv.

    $ env/bin/pip install -e demo
  • Run the pyramid_debugtoolbar package's demo/demo.py file using the virtual environment's Python.

    $ env/bin/python demo/demo.py

Visit http://localhost:8080 in a web browser to see a page full of test options.

Testing

If you have tox installed, run all tests with:

$ tox

To run only a specific Python environment:

$ tox -e py311

If you don't have tox installed, you can install the testing requirements, then run the tests.

$ python3 -m venv env
$ env/bin/pip install -e ".[testing]"
$ env/bin/py.test

Building documentation

If you have tox installed, build the docs with:

$ tox -e docs

If you don't have tox installed, you can install the requirements to build the docs, then build them.

$ env/bin/pip install -e ".[docs]"
$ cd docs
$ make clean html SPHINXBUILD=../env/bin/sphinx-build

pyramid_debugtoolbar's People

Contributors

aaronasachimp avatar bbangert avatar blaflamme avatar brodul avatar caseman avatar cguardia avatar chbrown avatar corehack avatar danclark5 avatar dependabot[bot] avatar dhaaker avatar digitalresistor avatar hanula avatar holgerpeters avatar inklesspen avatar j-carl avatar jvanasco avatar mcdonc avatar mmerickel avatar nbasu02 avatar nigelsmith avatar npilon avatar parly avatar pauleveritt avatar pieterproigia avatar rpatterson avatar stevepiercy avatar tseaver avatar wichert avatar wim-de-clercq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyramid_debugtoolbar's Issues

templates/headers.mako fails when environ['PATH_INFO'] contains unicode

The problem happens if I navigate to a URL that contains unicode.

I traced the problem to pyramid_debugtoolbar's use of markupsafe.escape(), which raises UnicodeDecodeError for any bit of unicode. However, cgi.escape() method is able to handle unicode without raising an exception.

I'm not sure how to work around this issue, so I will temporarily disable pyramid_debugtoolbar.

Pyramid itself has no problems with unicode URLs.

Debugtoolbar XHTML not valid

Hi,

I'm used to validate my work with WDG HTML Validator or the WebDeveloper plugin for Firefox.

If I activate pyramid_debugtoolbar (0.8), I have the following errors:

Line 1405, Column 8: document type does not allow element "thead" here
Line 1415, Column 8: document type does not allow element "thead" here

Moreover, it would be a good idea to integrate a tool as WDG (http://htmlhelp.com/tools/validator/) in pyramid_debugtoolbar.

Patrick

AttributeError with pyramid.renderers.null_renderer

Usage of null_renderer like this:

from pyramid.renderers import null_renderer

@view_config(route_name='test', renderer=null_renderer)
def test (request):
    def no_response (_environ, _start_response):
        return []
    return  no_response

causes exception:

...
  File "/home/f/proj/-/venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/toolbar.py", line 165, in toolbar_tween
    toolbar.process_response(response)
  File "/home/f/proj/-/venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/toolbar.py", line 45, in process_response
    panel.process_response(response)
  File "/home/f/proj/-/venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/panels/headers.py", line 24, in process_response
    (text_(k), text_(v)) for k, v in sorted(response.headerlist)
AttributeError: 'function' object has no attribute 'headerlist'

As a temporary solution, can i disable pyramid_debugtoolbar or its tween for this view only? (any hack would be ok, it's weird but real-world case)

DBT does not work on pages that use require.js

I am using require.js in my project. All my scripts are concatenated and minified into two files, which are loaded in my main template. This includes require.js.

This presumably causes pyramid_debugtoolbar's inclusion of require.js to bail out early, so that the dbt scripts are never loaded, unless I remove my own scripts.

How to reproduce

Enable pyramid_debugtoolbar on a page that includes require.js. See the following gist.

https://gist.github.com/3838851

sqla debugtoolbar load lazy attributes and create new queries

debugtoolbar load lazy attributes for each return objects in alchemy query. This overload application and pollutes result
without understanding origine. (those attributes are not loaded in template or view)

debug toolbar indicate the good number of queries but the list is completed by other queries. Those queries
loads attributes

pyramid_debugtoolbar and waitress leak support for non-english environments

Development Environment:
Debian GNU/Linux wheezy (locale: zh_TW.UTF-8)
Python 2.7.3rc2
waitress-0.8.1-py2.7
pyramid_debugtoolbar-1.0.2-py2.7
pyramid-1.3.3-py2.7

I wrote a page which would query and show content from my database, while the content stored in my database are all Chinese. If there is no errors on this page, everything works fine. But if this page raised errors, I will get this in browser:

Internal Server Error

The server encountered an unexpected internal server error

(generated by waitress)

in the console, I got his:

2012-09-10 09:31:27,486 ERROR [waitress][Dummy-2] Exception when serving /itemtype/1
Traceback (most recent call last):
  File "/home/bear/work/xxxx/pyenv/local/lib/python2.7/site-packages/waitress-0.8.1-py2.7.egg/waitress/channel.py", line 329, in service
    task.service()
  File "/home/bear/work/xxxx/pyenv/local/lib/python2.7/site-packages/waitress-0.8.1-py2.7.egg/waitress/task.py", line 173, in service
    self.execute()
  File "/home/bear/work/xxxx/pyenv/local/lib/python2.7/site-packages/waitress-0.8.1-py2.7.egg/waitress/task.py", line 380, in execute
    app_iter = self.channel.server.application(env, start_response)
  File "/home/bear/work/xxxx/pyenv/local/lib/python2.7/site-packages/pyramid-1.3.3-py2.7.egg/pyramid/router.py", line 187, in __call__
    response = self.handle_request(request)
  File "/home/bear/work/xxxx/pyenv/local/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.2-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 133, in toolbar_tween
    body = tb.render_full(request).encode('utf-8', 'replace')
  File "/home/bear/work/xxxx/pyenv/local/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.2-py2.7.egg/pyramid_debugtoolbar/tbtools.py", line 240, in render_full
    summary = self.render_summary(include_title=False, request=request)
  File "/home/bear/work/xxxx/pyenv/local/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.2-py2.7.egg/pyramid_debugtoolbar/tbtools.py", line 229, in render_summary
    'description':  description_wrapper % escape(self.exception),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 512: ordinal not in range(128)

Line 229 is not the only problem... there are more similar errors existed in pyramid_debugtoolbar.
If I removed pyramid_debugtoolbar form the development.ini, and I saw the bowser shown:

Internal Server Error

The server encountered an unexpected internal server error

(generated by waitress)

and in console:

AttributeError: 'ItemType' object has no attribute 'img'

 - Expression: "itemtype.img"
 - Filename:   None
 - Location:   (14:22)
 - Source:     <li tal:condition="itemtype.img">
                                  ^^^^^^^^^^^^
 - Arguments:  repeat: {...} (0)
               renderer_name: ../templates/itemtype.pt
               renderer_info: <RendererHelper - at 0x3c85690>
               imageserver: /static/images/
               itemtype: <ItemType - at 0x3d11d50>
               title: 测试商品
               request: <Request - at 0x3c85210>
               req: <Request - at 0x3c85210>
               amount: 0
               context: <instance None at 0x3ce78c0>
               view: <function itemtype_view at 0x3b99e60>

I believe it should show the error content in browser instead of a internal error page.

exception when remote IP makes no sense

  response = self.handle_request(request)
  File "pyramid_debugtoolbar/toolbar.py", line 108, in toolbar_tween
    if ipaddr.IPAddress(remote_addr) in ipaddr.IPNetwork(host):
  File "pyramid_debugtoolbar/ipaddr.py", line 85, in IPAddress
    address)
ValueError: '192.168.117.153, 216.53.134.86' does not appear to be an IPv4 or IPv6 address

pyramid-debugtoolbar==1.0.2

Using xmlrpc breaks the toolbar

When a view uses xmlrpclib the debugtoolbar always generates an execption:

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 35459)
Traceback (most recent call last):
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 639, in __init__
    self.handle()
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 343, in handle
    self.handle_one_request()
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/home/wichert/lib/buildout/eggs/repoze.zodbconn-0.12-py2.7.egg/repoze/zodbconn/connector.py", line 21, in __call__
    result = self.next_app(environ, start_response)
  File "/home/wichert/lib/buildout/eggs/repoze.retry-1.0-py2.7.egg/repoze/retry/__init__.py", line 90, in __call__
    app_iter = self.application(environ, replace_start_response)
  File "/home/wichert/lib/buildout/eggs/repoze.tm2-1.0b1-py2.7.egg/repoze/tm/__init__.py", line 23, in __call__
    result = self.application(environ, save_status_and_headers)
  File "/home/wichert/lib/buildout/eggs/repoze.filesafe-2.0b1-py2.7.egg/repoze/filesafe/__init__.py", line 59, in __call__
    return self.app(environ, start_response)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a5-py2.7.egg/pyramid/router.py", line 176, in __call__
    response = self.handle_request(request)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.9.3-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 150, in toolbar_tween
    toolbar.process_response(response)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.9.3-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 50, in process_response
    vars, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a5-py2.7.egg/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a5-py2.7.egg/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/wichert/lib/buildout/eggs/pyramid_jinja2-1.1-py2.7.egg/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/wichert/lib/buildout/eggs/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.9.3-py2.7.egg/pyramid_debugtoolbar/templates/toolbar.jinja2", line 62, in top-level template code
    {{ panel.content()|safe }}
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.9.3-py2.7.egg/pyramid_debugtoolbar/panels/settings.py", line 57, in content
    vars, self.request)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.9.3-py2.7.egg/pyramid_debugtoolbar/panels/__init__.py", line 24, in render
    return render(template_name, vars, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a5-py2.7.egg/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a5-py2.7.egg/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/wichert/lib/buildout/eggs/pyramid_jinja2-1.1-py2.7.egg/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/wichert/lib/buildout/eggs/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.9.3-py2.7.egg/pyramid_debugtoolbar/panels/templates/settings.jinja2", line 12, in top-level template code
    <td>{{ value|escape }}</td>
  File "/usr/lib/python2.7/xmlrpclib.py", line 1224, in __call__
    return self.__send(self.__name, args)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1575, in __request
    verbose=self.__verbose
  File "/usr/lib/python2.7/xmlrpclib.py", line 1264, in request
    return self.single_request(host, handler, request_body, verbose)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1297, in single_request
    return self.parse_response(response)
  File "/usr/lib/python2.7/xmlrpclib.py", line 1473, in parse_response
    return u.close()
  File "/usr/lib/python2.7/xmlrpclib.py", line 793, in close
    raise Fault(**self._stack[0])
Fault: <Fault 0: 'No such handler: __html__'>
----------------------------------------

Show debugtoolbar on exception only

I think it may be a useful feature to show the debugtoolbar only if an exception occurs and not by default.
If you are using iframes or right aligned html blocks the toollbar interferes with the page and may overlay some part.

An additional configuration option to hide the toolbar button/overlay by default would be much help.
Maybe extend "debugtoolbar.enabled" or "debugtoolbar.intercept_exc" with another option? I'm not sure about the best way to do this.

Arndt.

UnicodeDecodeError when string representation of context contains accented characters.

So I have a simple view that returns a MongoDB dataset:

def region_selector(request):
    return {
        'regions': Region.objects.all()
        }

But since I added a unicode method to my Region model, pyramid_debugtoolbar breaks. Here's the stack:

Traceback (most recent call last):
  File "/sites/envs/tuktu/local/lib/python2.7/site-packages/pyramid/mako_templating.py", line 181, in __call__
    result = template.render_unicode(**system)
  File "/sites/envs/tuktu/local/lib/python2.7/site-packages/Mako-0.7.0-py2.7.egg/mako/template.py", line 406, in render_unicode
    as_unicode=True)
  File "/sites/envs/tuktu/local/lib/python2.7/site-packages/Mako-0.7.0-py2.7.egg/mako/runtime.py", line 764, in _render
    **_kwargs_for_callable(callable_, data))
  File "/sites/envs/tuktu/local/lib/python2.7/site-packages/Mako-0.7.0-py2.7.egg/mako/runtime.py", line 796, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/sites/envs/tuktu/local/lib/python2.7/site-packages/Mako-0.7.0-py2.7.egg/mako/runtime.py", line 822, in _exec_template
    callable_(context, *args, **kwargs)
  File "/sites/envs/tuktu/local/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.2-py2.7.egg/pyramid_debugtoolbar/panels/templates/renderings.dbtmako", line 21, in render_body
    <td colspan="2">${rendering['val']|h}</td>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 30: ordinal not in range(128)

I enabled pdb in renderings.py, in function content, maybe it will help:

> /sites/envs/tuktu/local/lib/python2.7/site-packages/pyramid_debugtoolbar-1.0.2-py2.7.egg/pyramid_debugtoolbar/panels/renderings.py(44)content()
-> return self.render(
(Pdb) print self.renderings[0]['val']
{'regions': [<Region: SaguenayLac-Saint-Jean>, <Region: GaspésieÎles-de-la-Madeleine>, <Region: Lanaudière>, <Region: Chaudière-Appalaches>, <Region: Montréal>, <Region: Nord-du-Québec>, <Region: Mauricie>, <Region: Côte-Nord>, <Region: Montérégie>, <Region: Bas-Saint-Laurent>, <Region: Abitibi-Témiscamingue>, <Region: Centre-du-Québec>, <Region: Laurentides>, <Region: Laval>, <Region: Outaouais>, <Region: Estrie>, <Region: Saint-Pierre et Miquelon>, <Region: t2>, <Region: t1>]}
(Pdb) 

Note that the data type above is str.

sqla panel - max number of queries

It wouldn't hurt to add a setting to cap the number of queries that the panel actually tracks per request. It's possible someone is doing a loop, adding a bunch of objects, etc, and there can be some significant performance impact (request time and memory usage) to store all of these queries.

error with webob1.2b1

using with webob1.2b1 causes error.
webob1.1 works well.

Exception happened during processing of request from ('127.0.0.1', 50762)
Traceback (most recent call last):
File "/Users/sin/.virtualenvs/py2.7.2/lib/python2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
self.finish_request(request, client_address)
File "/Users/sin/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/Users/sin/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/SocketServer.py", line 639, in init
self.handle()
File "/Users/sin/.virtualenvs/py2.7.2/lib/python2.7/site-packages/paste/httpserver.py", line 442, in handle
BaseHTTPRequestHandler.handle(self)
File "/Users/sin/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/BaseHTTPServer.py", line 343, in handle
self.handle_one_request()
File "/Users/sin/.virtualenvs/py2.7.2/lib/python2.7/site-packages/paste/httpserver.py", line 437, in handle_one_request
self.wsgi_execute()
File "/Users/sin/.virtualenvs/py2.7.2/lib/python2.7/site-packages/paste/httpserver.py", line 287, in wsgi_execute
self.wsgi_start_response)
File "/Users/sin/.virtualenvs/py2.7.2/lib/python2.7/site-packages/pyramid/router.py", line 176, in call
response = self.handle_request(request)
File "/Users/sin/.virtualenvs/py2.7.2/lib/python2.7/site-packages/pyramid_debugtoolbar/toolbar.py", line 105, in toolbar_tween
toolbar = DebugToolbar(request, panel_classes)
File "/Users/sin/.virtualenvs/py2.7.2/lib/python2.7/site-packages/pyramid_debugtoolbar/toolbar.py", line 27, in init
p_dt_active = url_unquote(self.request.cookies.get('p_dt_active', ''))
File "/Users/sin/.pythonbrew/pythons/Python-2.7.2/lib/python2.7/urllib.py", line 1186, in unquote
res = s.split('%')
AttributeError: 'NoneType' object has no attribute 'split'

pdtb_sqla_queries cause "memory leak" in long running pyramid script

Let's say I have a long running pyramid script (with the standard paster bootstrap) that repeats the same SQLAlchemy query once every 2 seconds. After a while, maybe 30 minutes or so, the machine will swap itself to near-death, until the script eventually get killed by the OOM killer.

The memory usage stays constant if I remove pyramid_debugtoolbar from pyramid.includes, so I believe it is pdtb_sqla_queries that causes the "memory leak".

As the debug toolbar is really great during development, I don't want to remove it from pyramid.includes. Is there a better workaround than maintaining separate .ini files for web and script?

SettingsDebugPanel doesn't work with pymongo

SettingsDebugPanel doesn't work with pymongo

Traceback (most recent call last):
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 639, in __init__
    self.handle()
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 343, in handle
    self.handle_one_request()
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid/router.py", line 176, in __call__
    response = self.handle_request(request)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/toolbar.py", line 150, in toolbar_tween
    toolbar.process_response(response)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/toolbar.py", line 50, in process_response
    vars, request=request)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/templates/toolbar.jinja2", line 62, in top-level template code
    {{ panel.content()|safe }}
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/panels/settings.py", line 57, in content
    vars, self.request)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/panels/__init__.py", line 24, in render
    return render(template_name, vars, request=request)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar/panels/templates/settings.jinja2", line 12, in top-level template code
    <td>{{ value|escape }}</td>
  File "/home/Documents/development/venvs/pyramid-1.2-venv/local/lib/python2.7/site-packages/pymongo/database.py", line 682, in __call__
    "failing because no such method exists." % self.__name)
TypeError: 'Database' object is not callable. If you meant to call the '__html__' method on a 'Connection' object it is failing because no such method exists.

The demo app does not run on windows

The application returns an internal server error and dumps this stack trace:

Traceback (most recent call last):
File "c:\Python27\Lib\wsgiref\handlers.py", line 85, in run
self.result = application(self.environ, self.start_response)
File "c:\sandboxen\people\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyramid\router.py", line 176, in call
response = self.handle_request(request)
File "c:\sprint\pyramid_debugtoolbar\pyramid_debugtoolbar\toolbar.py", line 133, in toolbar_tween
body = tb.render_full(request).encode('utf-8', 'replace')
File "c:\sprint\pyramid_debugtoolbar\pyramid_debugtoolbar\tbtools.py", line 240, in render_full
summary = self.render_summary(include_title=False, request=request)
File "c:\sprint\pyramid_debugtoolbar\pyramid_debugtoolbar\tbtools.py", line 233, in render_summary
vars, request=request)
File "c:\sandboxen\people\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyramid\renderers.py", line 69, in render
return helper.render(value, None, request=request)
File "c:\sandboxen\people\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyramid\renderers.py", line 418, in render
result = renderer(value, system_values)
File "c:\sandboxen\people\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyramid\mako_templating.py", line 143, in call
template = self.implementation()
File "c:\sandboxen\people\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyramid\mako_templating.py", line 130, in implementation
return self.lookup.get_template(self.path)
File "c:\sandboxen\people\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyramid\mako_templating.py", line 51, in get_template
return self._load(srcfile, uri)
File "c:\sandboxen\people\lib\site-packages\mako\lookup.py", line 283, in _load
**self.template_args)
File "c:\sandboxen\people\lib\site-packages\mako\template.py", line 224, in init
module = self._compile_from_file(path, filename)
File "c:\sandboxen\people\lib\site-packages\mako\template.py", line 242, in _compile_from_file
util.verify_directory(os.path.dirname(path))
File "c:\sandboxen\people\lib\site-packages\mako\util.py", line 76, in verify_directory
os.makedirs(dir, 0775)
File "c:\sandboxen\people\lib\os.py", line 157, in makedirs
mkdir(name, mode)
WindowsError: [Error 267] The directory name is invalid: 'c:\sprint\pyramid_debugtoolbar\demo\mako_modules\pyramid_debugto
olbar:templates'
LT-FALCIONI.Amyris.local - - [13/Mar/2012 14:59:23] "GET / HTTP/1.1" 500 59

Toolbar does not work with Dojo

Unfortunately, the pyramid_debugtoolbar does not work with Pyramid applications which are using Dojo. The reason is that Dojo comes with its own implementation of require which is incompatible with require.js used by pyramid_debugtoolbar.

I think this should be fixed by removing require.js from pyramid_debugtoolbar, I think it does more harm than good. The toolbar should just use jquery directly, and make use of jQuery.noConflict.

Calling method join on a list in request_vars.mako

Template pyramid_debugtoolbar/panels/templates/request_vars.mako calls method join on a list on rows 66 and 88. Should call join on a string with a list.

                                     <td>${value.join(", ")|h}</td>

should be

                                     <td>${", ".join(value)|h}</td>

Version: 0.9.4post1

enable debugtoolbar for all hosts

The toolbar should allow a '*' or '0.0.0.0' address to enable the toolbar for everyone. The other option would be to just make this the default and update the pyramid scaffolds to use hosts = 127.0.0.1 ::1

UnicodeDecodeError for sql queries containing unicode

  File "/home/f/venvs/x/local/lib/python2.7/site-packages/mako/runtime.py", line 704, in _exec_template
    callable_(context, *args, **kwargs)
  File "/home/f/venvs/x/local/lib/python2.7/site-packages/pyramid_debugtoolbar/templates/toolbar.dbtmako", line 61, in render_body
    ${panel.content()|n}
  File "/home/f/venvs/x/local/lib/python2.7/site-packages/pyramid_debugtoolbar/panels/sqla.py", line 103, in content
    need = self.request.exc_history.token + stmt + params
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 175: ordinal not in range(128)

Should i provide some more info?
Excerpt from query printed to terminal: tags LIKE '%%#\u0442\u0435\u0441\u0442#%%' (it's "тест" in russian)
I get input from request.POST, retrieve this value with some regexp and construct a part of query by hand i.e. u"tags LIKE '%%#%s#%%'" % match

Wrap long error messages

The error message text inside of the error page header overflows the page quite frequently, especially if a system path is involved.

Race condition when accessing sqla's pdtb_start_timer

When running my pyramid application via waitress, simultaneous (or near-simultaeous) requests sometimes fail with:

...
  File "/Network/Cluster/home/luke/.virtualenvs/pyramid/lib/python2.6/site-packages/pyramid_debugtoolbar/panels/sqla.py", line 47, in _after_cursor_execute
    'duration': stop_timer - conn.pdtb_start_timer,
AttributeError: 'Connection' object has no attribute 'pdtb_start_timer'

I believe this is because multiple queries are executing simultaneously on the same connection, so:

  1. Query A causes the sqla panel to set pdtb_start_timer on the Connection object
  2. Query B does the same, overwriting the same attribute
  3. Query A completes, reads the attribute and deletes it
  4. Query B completes, tries to read the attribute but it's already gone

Perhaps the attribute should be stashed in the cursor object rather than the connection object, or perhaps I'm doing something majorly wrong. Unfortunately I'm stretching my knowledge of SQLAlchemy and am not in a position to submit a patch. Let me know how I can help solve this.

Intermittent issue with loading javascript dependencies in interactive console

Loading the interactive console appears to suffer from a timing error of some kind with loading the jquery dependency.

Going to the traceback url I get this error in the chrome debug console:

Uncaught TypeError: Cannot call method 'extend' of undefined :6543/_debug_toolbar/static/js/toolbar.js:8

The page loads but all the javascript functionality does not. After loading the page once, if I refresh with the page cache it typically seems to work but if I do a full page refresh I'm likely to get this error again ...

This is with
pyramid-debugtoolbar==1.0.2
pyramid==1.3.2

'NoneType' object has no attribute 'split'

Made a brand new pyramid installation this morning. Followed the basic steps:

# new virtualenv
# pip install pyramid
# paster create -t pyramid_routesalchemy app
# cd app
# python setup.py develop
# paster serve develpment.ini

Visited the page in my browser, and immediately get this (truncated for clarity):

  File "/home/dave/.virtualenvs/app/lib/python2.7/site-packages/pyramid/router.py", line 176, in __call__
    response = self.handle_request(request)
  File "/home/dave/.virtualenvs/app/lib/python2.7/site-packages/pyramid_debugtoolbar-0.9.4-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 105, in toolbar_tween
    toolbar = DebugToolbar(request, panel_classes)
  File "/home/dave/.virtualenvs/app/lib/python2.7/site-packages/pyramid_debugtoolbar-0.9.4-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 27, in __init__
    p_dt_active = url_unquote(self.request.cookies.get('p_dt_active', ''))
  File "/usr/lib/python2.7/urllib.py", line 1203, in unquote
    res = s.split('%')
AttributeError: 'NoneType' object has no attribute 'split'

Fix for me was to replace:

p_dt_active = url_unquote(self.request.cookies.get('p_dt_active', ''))

with:

p_dt_active = url_unquote(self.request.cookies.get('p_dt_active') or '')

Exception in interactive console chains in application exception

Steps to reproduce

  • create intentional syntax error in a view
  • open that view, when you see the traceback, start interactive console
  • in interactive console, type something that will result in traceback, for example syntaxerror
  • if there is subscribed event to BeforeRender, which does something similar like this
def custom_event(event):
    request = event['request']
    # do something with request, this will fail since request will be None

Expected result:

traceback in web console

Actual result:

request object in event dictionary will be None, code using the request object will result in second unwanted exception breaking interactive console

Logging to console verbose with toolbar

When the debug toolbar is added, the root logger gets changed from "INFO" to "NOTSET" level unconditionally. I assume this is done so that the debug tool bar can display as many log entries as possible.

However, this has a side effect of enabling a lot of extraneous debug logging on the console as well...

I am not sure if there is a better way to deal with this?

visiting % encoded unicode url caused Exception

For example, if your page is at http://localhost/blog/2012/03/22/%E6%B5%8B%E8%AF%95%E4%B8%80%E4%B8%8B/, this
would result in the following exception.

D:\Dropbox\Pharaoh>paster serve development.ini
2012-03-22 20:12:33,717 INFO [sqlalchemy.engine.base.Engine][MainThread] PRAGMA
table_info("guestbook")
2012-03-22 20:12:33,717 INFO [sqlalchemy.engine.base.Engine]MainThread
2012-03-22 20:12:33,717 INFO [sqlalchemy.engine.base.Engine][MainThread] PRAGMA
table_info("slideshow")
2012-03-22 20:12:33,717 INFO [sqlalchemy.engine.base.Engine]MainThread
2012-03-22 20:12:33,717 INFO [sqlalchemy.engine.base.Engine][MainThread] PRAGMA
table_info("users")
2012-03-22 20:12:33,717 INFO [sqlalchemy.engine.base.Engine]MainThread
Starting server in PID 6076.
serving on 0.0.0.0:6543 view at http://127.0.0.1:6543
2012-03-22 20:12:42,233 INFO [sqlalchemy.engine.base.Engine][worker 0] BEGIN (i
mplicit)
2012-03-22 20:12:42,233 INFO [sqlalchemy.engine.base.Engine][worker 0] SELECT s
lideshow.id AS slideshow_id, slideshow.title AS slideshow_title, slideshow.descr
iption AS slideshow_description, slideshow."imgUrl" AS "slideshow_imgUrl", slide
show.url AS slideshow_url
FROM slideshow

2012-03-22 20:12:42,250 INFO [sqlalchemy.engine.base.Engine]worker 0

Exception happened during processing of request from ('127.0.0.1', 4660)
Traceback (most recent call last):
File "C:\Program Files\Python27\lib\site-packages\paste-1.7.5.1-py2.7.egg\past
e\httpserver.py", line 1068, in process_request_in_thread
self.finish_request(request, client_address)
File "C:\Program Files\Python27\lib\SocketServer.py", line 323, in finish_requ
est
self.RequestHandlerClass(request, client_address, self)
File "C:\Program Files\Python27\lib\SocketServer.py", line 639, in init
self.handle()
File "C:\Program Files\Python27\lib\site-packages\paste-1.7.5.1-py2.7.egg\past
e\httpserver.py", line 442, in handle
BaseHTTPRequestHandler.handle(self)
File "C:\Program Files\Python27\lib\BaseHTTPServer.py", line 343, in handle
self.handle_one_request()
File "C:\Program Files\Python27\lib\site-packages\paste-1.7.5.1-py2.7.egg\past
e\httpserver.py", line 437, in handle_one_request
self.wsgi_execute()
File "C:\Program Files\Python27\lib\site-packages\paste-1.7.5.1-py2.7.egg\past
e\httpserver.py", line 287, in wsgi_execute
self.wsgi_start_response)
File "C:\Program Files\Python27\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyra
mid\router.py", line 176, in call
response = self.handle_request(request)
File "C:\Program Files\Python27\lib\site-packages\pyramid_debugtoolbar-0.9.4-p
y2.7.egg\pyramid_debugtoolbar\toolbar.py", line 157, in toolbar_tween
toolbar.process_response(response)
File "C:\Program Files\Python27\lib\site-packages\pyramid_debugtoolbar-0.9.4-p
y2.7.egg\pyramid_debugtoolbar\toolbar.py", line 55, in process_response
vars, request=request)
File "C:\Program Files\Python27\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyra
mid\renderers.py", line 69, in render
return helper.render(value, None, request=request)
File "C:\Program Files\Python27\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyra
mid\renderers.py", line 418, in render
result = renderer(value, system_values)
File "C:\Program Files\Python27\lib\site-packages\pyramid_jinja2-1.2-py2.7.egg
\pyramid_jinja2__init__.py", line 287, in call
return self.template.render(system)
File "C:\Program Files\Python27\lib\site-packages\jinja2-2.6-py2.7.egg\jinja2
environment.py", line 894, in render
return self.environment.handle_exception(exc_info, True)
File "C:\Program Files\Python27\lib\site-packages\pyramid_debugtoolbar-0.9.4-p
y2.7.egg\pyramid_debugtoolbar\templates\toolbar.jinja2", line 62, in top-level t
emplate code
{{ panel.content()|safe }}
File "C:\Program Files\Python27\lib\site-packages\pyramid_debugtoolbar-0.9.4-p
y2.7.egg\pyramid_debugtoolbar\panels\headers.py", line 54, in content
vars, self.request)
File "C:\Program Files\Python27\lib\site-packages\pyramid_debugtoolbar-0.9.4-p
y2.7.egg\pyramid_debugtoolbar\panels__init__.py", line 24, in render
return render(template_name, vars, request=request)
File "C:\Program Files\Python27\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyra
mid\renderers.py", line 69, in render
return helper.render(value, None, request=request)
File "C:\Program Files\Python27\lib\site-packages\pyramid-1.2.1-py2.7.egg\pyra
mid\renderers.py", line 418, in render
result = renderer(value, system_values)
File "C:\Program Files\Python27\lib\site-packages\pyramid_jinja2-1.2-py2.7.egg
\pyramid_jinja2__init__.py", line 287, in call
return self.template.render(system)
File "C:\Program Files\Python27\lib\site-packages\jinja2-2.6-py2.7.egg\jinja2
environment.py", line 894, in render
return self.environment.handle_exception(exc_info, True)
File "C:\Program Files\Python27\lib\site-packages\pyramid_debugtoolbar-0.9.4-p
y2.7.egg\pyramid_debugtoolbar\panels\templates\headers.jinja2", line 13, in top-
level template code
{{ value|escape }}
File "C:\Program Files\Python27\lib\site-packages\markupsafe-0.15-py2.7.egg\ma
rkupsafe_native.py", line 21, in escape
return Markup(unicode(s)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 11: ordinal

not in range(128)

pyramid_debugtoolbar 0.9.6 raises NameError when used with mako.strict_undefined = true

The performance panel of the debugtoolbar uses a variable function_calls which is not initialised when no stats are collected. This causes a NameError when mako renders the template with the strict_undefined option.
The following patch fixes this problem:

$ diff lib/python2.6/site-packages/pyramid_debugtoolbar/panels/performance.py lib/python2.6/site-packages/pyramid_debugtoolbar/panels/performance.py.orig
161c161

< vars = {'timing_rows':None, 'stats':None, 'function_calls':[]}

    vars = {'timing_rows':None, 'stats':None}

encoding problems

there's some encoding problems, pyramid_debugtoolbar try to create a template with request vars and crash.
It's easy to reproduce, I've try it with lot's of different projects.
The easiest is shootout project (https://github.com/virhilo/shootout.git), (just a little correction in login.pt, an include
tag without '/>')

(thx for this beautiful project !)

the exception :

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 3462: ordinal not in range(128)

the full traceback

URL: http://localhost:6543/
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/WebError-0.10.3-py2.6.egg/weberror/evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/repoze.tm2-1.0b1-py2.6.egg/repoze/tm/init.py', line 23 in call
result = self.application(environ, save_status_and_headers)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/router.py', line 186 in call
response = self.handle_request(request)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/toolbar.py', line 137 in toolbar_tween
toolbar.process_response(response)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/toolbar.py', line 43 in process_response
vars, request=request)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 69 in render
return helper.render(value, None, request=request)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 416 in render
result = renderer(value, system_values)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_jinja2-1.1-py2.6.egg/pyramid_jinja2/init.py', line 277 in call
return self.template.render(system)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/Jinja2-2.5.5-py2.6.egg/jinja2/environment.py', line 891 in render
return self.environment.handle_exception(exc_info, True)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/templates/toolbar.jinja2', line 62 in top-level template code
{{ panel.content()|safe }}
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/panels/request_vars.py', line 45 in content
request=self.request)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/panels/init.py', line 24 in render
return render(template_name, vars, request=request)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 69 in render
return helper.render(value, None, request=request)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 416 in render
result = renderer(value, system_values)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_jinja2-1.1-py2.6.egg/pyramid_jinja2/init.py', line 277 in call
return self.template.render(system)
File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/Jinja2-2.5.5-py2.6.egg/jinja2/environment.py', line 891 in render
return self.environment.handle_exception(exc_info, True)
URL: http://localhost:6543/
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/WebError-0.10.3-py2.6.egg/weberror/evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/repoze.tm2-1.0b1-py2.6.egg/repoze/tm/init.py', line 23 in call
result = self.application(environ, save_status_and_headers)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/router.py', line 186 in call
response = self.handle_request(request)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/toolbar.py', line 137 in toolbar_tween
toolbar.process_response(response)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/toolbar.py', line 43 in process_response
vars, request=request)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 69 in render
return helper.render(value, None, request=request)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 416 in render
result = renderer(value, system_values)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_jinja2-1.1-py2.6.egg/pyramid_jinja2/init.py', line 277 in call
return self.template.render(system)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/Jinja2-2.5.5-py2.6.egg/jinja2/environment.py', line 891 in render
return self.environment.handle_exception(exc_info, True)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/templates/toolbar.jinja2', line 62 in top-level template code
{{ panel.content()|safe }}
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/panels/request_vars.py', line 45 in content
request=self.request)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/panels/init.py', line 24 in render
return render(template_name, vars, request=request)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 69 in render
return helper.render(value, None, request=request)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid-1.1.1dev-py2.6.egg/pyramid/renderers.py', line 416 in render
result = renderer(value, system_values)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_jinja2-1.1-py2.6.egg/pyramid_jinja2/init.py', line 277 in call
return self.template.render(system)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/Jinja2-2.5.5-py2.6.egg/jinja2/environment.py', line 891 in render
return self.environment.handle_exception(exc_info, True)
File '/home/sbard/geek/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/panels/templates/request_vars.jinja2', line 110 in top-level template code

{{ value|escape }} UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 3462: ordinal not in range(128)File '/home/tuck/dev/python/pyramide/myvenv/lib/python2.6/site-packages/pyramid_debugtoolbar-0.2-py2.6.egg/pyramid_debugtoolbar/panels/templates/request_vars.jinja2', line 110 in top-level template code {{ value|escape }} UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 3462: ordinal not in range(128)

debugtoolbar crash if response is an HTTPFound object

HTTPFound object is instance of WSGIHTTPException but don't have prepare method

URL: http://127.0.0.1:6543/closesession
File 'C:\DEV\py27venv\lib\site-packages\weberror-0.10.3-py2.7.egg\weberror\evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File 'C:\DEV\py27venv\lib\site-packages\repoze.tm2-1.0b1-py2.7.egg\repoze\tm*init*.py', line 23 in call
result = self.application(environ, save_status_and_headers)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.2dev-py2.7.egg\pyramid\router.py', line 176 in call
response = self.handle_request(request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 141 in toolbar_tween
toolbar.process_response(response)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 36 in process_response
response.prepare(request.environ)
AttributeError: 'HTTPFound' object has no attribute 'prepare'

Add config option to use request.client_addr

As you know (from Issue #53), remote_addr and client_addr are approximately assigned like this:

request.remote_addr = environ.get('REMOTE_ADDR')
request.client_addr = environ.get('HTTP_X_FORWARDED_FOR', request.remote_addr)

Using client_addr would allow the debugtoolbar to be used behind a proxy or load balancer. However, it would be insecure to blindly trust the X-Forwarded-For header since a malicious client could set it when accessing a webserver that doesn't run behind a proxy.

The simplest solution seems to be to add a config setting for this. A more elaborate solution would be to maintain a list of allowed proxy IPs and then only consult client_addr when the remote_addr is in the list of proxy IPs.

LoggingPanel not working ...

The LoggingPanel displays in the ui toolbar but never shows any logged messages ... Does it work for anybody else?

I mostly understand the python logging system and am able to successfully control logging output to other handlers (like the console handler) via the pyramid ini file -- however I can't figure out how to get anything to appear in the LoggingPanel ...

I've even gone so far as to try to add the handler within the pane to a logging instance which I KNOW is correctly configured to generate output to other handlers ...

from pyramid_debugtoolbar.panels.logger import handler
logger.addHandler(handler)

Any advice appreciated,

Ben

New session is created on each request

When pyramid_debugtoolbar is enabled, i get new session cookie on each request (if i remove pyramid_debugtoolbar from pyramid.includes, session is not being recreated)
Session setup is just default:

config = Configurator(
    settings = settings,
    session_factory = pyramid.session.UnencryptedCookieSessionFactoryConfig('secret'),
)

Does anyone else have this bug? I can't test session csrf token handling because i get new token in new session on each request :[

Template raises UnicodeDecodeError for non-ascii values in settings

The settings.jinja2 template raises a UnicodeDecodeError exception if settings contains a non-ascii value, such as a string of bytes generated by os.urandom().

To circumvent the issue, I added the following code to the end of settings.py.

class SettingsDebugPanel(DebugPanel):

    def content(self):
        vars = {
            'settings': [(k, decode_safely(v)) for k, v in self.settings]
        }
        return self.render(
            'pyramid_debugtoolbar.panels:templates/settings.jinja2',
            vars, self.request)


def decode_safely(x):
    try:
        return x.decode('utf-8', 'replace')
    except AttributeError:
        return x

https://github.com/Pylons/pyramid_debugtoolbar/blob/master/pyramid_debugtoolbar/panels/settings.py

debugtoolbar crash on attribute error

pyramid debugtoolbar last tip (3ff51ce) crash

AttributeError: 'PerformanceDebugPanel' object has no attribute '_end_rusage'

URL: http://127.0.0.1:6543/
File 'C:\DEV\py27venv\lib\site-packages\weberror-0.10.3-py2.7.egg\weberror\evalexception.py', line 431 in respond
app_iter = self.application(environ, detect_start_response)
File 'C:\DEV\py27venv\lib\site-packages\repoze.tm2-1.0b1-py2.7.egg\repoze\tm*init*.py', line 23 in call
result = self.application(environ, save_status_and_headers)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.1.1dev-py2.7.egg\pyramid\router.py', line 176 in call
response = self.handle_request(request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 137 in toolbar_tween
toolbar.process_response(response)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\toolbar.py', line 43 in process_response
vars, request=request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.1.1dev-py2.7.egg\pyramid\renderers.py', line 69 in render
return helper.render(value, None, request=request)
File 'C:\DEV\py27venv\lib\site-packages\pyramid-1.1.1dev-py2.7.egg\pyramid\renderers.py', line 416 in render
result = renderer(value, system_values)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_jinja2-1.1-py2.7.egg\pyramid_jinja2*init*.py', line 277 in call
return self.template.render(system)
File 'C:\DEV\py27venv\lib\site-packages\jinja2-2.6-py2.7.egg\jinja2\environment.py', line 894 in render
return self.environment.handle_exception(exc_info, True)
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\templates\toolbar.jinja2', line 62 in top-level template code
{{ panel.content()|safe }}
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\panels\performance.py', line 157 in content
utime = 1000 * self._elapsed_ru('ru_utime')
File 'C:\DEV\py27venv\lib\site-packages\pyramid_debugtoolbar-0.2-py2.7.egg\pyramid_debugtoolbar\panels\performance.py', line 153 in _elapsed_ru
return getattr(self._end_rusage, name) - getattr(self._start_rusage,
AttributeError: 'PerformanceDebugPanel' object has no attribute '_end_rusage'

Add option to hide by default

The toolbar should have an option to start in hidden mode by default. Currently, it stores the shown/hidden mode in a 'hide' cookie value, but defaults to showing when the cookie is not present. This is rather annoying when you have to remove your cookies often (such as in acceptance tests or multi-browser/multi-profile setups).

standalone exception handler

It might be nice to have an option to use pyramid_debugtoolbar's debugger like weberror's exc handler. In this case, the toolbar code would not be loaded, the JS would not be injected, but the tween (or whatever is catching the exceptions) would still be installed.

This may not be a useful configuration if #75 is implemented. It depends on how much of the JS and CSS for the toolbar can be left out when running in exception-handler-only mode.

Breakdown of log message count

Views having log messages is normal, but having messages with level="error" is not -- it'd be nice if there was some way to tell without having to open the logging tab and manually scan the list every time, eg replace "4 messages" with "4 messages (3 debug, 1 warning)", or "4 messages (3 / 1)" colouring the numbers to show the levels

Error in FireFox

Hello,

I am using git version of pyramid_debugtoolbar with the git version of pyramid. It seems to be a great and very useful tool.

I have just a remark:

In FireFox 5.0 (Debian Wheezy), it generates the two following errors:
Error in parsing value for 'left'. Declaration dropped.
Error in parsing value for 'top'. Declaration dropped.

And a suggestion:

The tab is a bit intrusive. We could set its size and position in configuration file.

Patrick.

Aborts with TypeError

I wanted to try the debugtoolbar, but after adding a config.include for it I get this traceback on every request:

Exception happened during processing of request from ('127.0.0.1', 33517)
Traceback (most recent call last):
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 639, in __init__
    self.handle()
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 343, in handle
    self.handle_one_request()
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/home/wichert/lib/buildout/eggs/Paste-1.7.5.1-py2.7.egg/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/home/wichert/lib/buildout/eggs/repoze.zodbconn-0.12-py2.7.egg/repoze/zodbconn/connector.py", line 21, in __call__
    result = self.next_app(environ, start_response)
  File "/home/wichert/lib/buildout/eggs/repoze.retry-1.0-py2.7.egg/repoze/retry/__init__.py", line 90, in __call__
    app_iter = self.application(environ, replace_start_response)
  File "/home/wichert/lib/buildout/eggs/repoze.tm2-1.0b1-py2.7.egg/repoze/tm/__init__.py", line 23, in __call__
    result = self.application(environ, save_status_and_headers)
  File "/home/wichert/lib/buildout/eggs/repoze.filesafe-1.1-py2.7.egg/repoze/filesafe/__init__.py", line 38, in __call__
    return self.app(environ, start_response)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a1-py2.7.egg/pyramid/router.py", line 176, in __call__
    response = self.handle_request(request)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.8-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 142, in toolbar_tween
    toolbar.process_response(response)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.8-py2.7.egg/pyramid_debugtoolbar/toolbar.py", line 48, in process_response
    vars, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a1-py2.7.egg/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a1-py2.7.egg/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/wichert/lib/buildout/eggs/pyramid_jinja2-1.1-py2.7.egg/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/wichert/lib/buildout/eggs/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.8-py2.7.egg/pyramid_debugtoolbar/templates/toolbar.jinja2", line 62, in top-level template code
    {{ panel.content()|safe }}
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.8-py2.7.egg/pyramid_debugtoolbar/panels/renderings.py", line 40, in content
    }, request=self.request)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.8-py2.7.egg/pyramid_debugtoolbar/panels/__init__.py", line 24, in render
    return render(template_name, vars, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a1-py2.7.egg/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/wichert/lib/buildout/eggs/pyramid-1.2a1-py2.7.egg/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/wichert/lib/buildout/eggs/pyramid_jinja2-1.1-py2.7.egg/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/wichert/lib/buildout/eggs/Jinja2-2.6-py2.7.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/wichert/lib/buildout/eggs/pyramid_debugtoolbar-0.8-py2.7.egg/pyramid_debugtoolbar/panels/templates/renderings.jinja2", line 21, in top-level template code
    <td colspan="2">{{ rendering.val|escape }}</td>
  File "/home/wichert/lib/buildout/eggs/formish-0.9.1-py2.7.egg/formish/forms.py", line 961, in __repr__
    if self.defaults._o != {}:
  File "/home/wichert/lib/buildout/eggs/formish-0.9.1-py2.7.egg/formish/forms.py", line 1049, in _get_defaults
    return dotted(self._defaults)
  File "/home/wichert/lib/buildout/eggs/dottedish-0.6-py2.7.egg/dottedish/api.py", line 20, in dotted
    raise TypeError(type(o))
TypeError: <class 'pyramid_beaker.PyramidBeakerSessionObject'>

request_vars.mako template does not handle forms with file data

With a POST request from form accepting multipart/form-data containing a file request_vars.mako raises an exception

  File "/venv/local/lib/python2.7/site-packages/pyramid_debugtoolbar-0.9.4post2-py2.7.egg/pyramid_debugtoolbar/panels/templates/request_vars.mako", line 88, in render_body
    <td>${", ".join(value)|h}</td>
TypeError: sequence item 0: expected string, instance found

It seems PDT is given a ready made instance instead of a plain string. A quick hack would be to

<td>${", ".join(isinstance(val, (str, unicode)) and val or repr(val) for val in value)|h}</td>

... or handle values before giving them to template (the better solution?).

URLs with special characters

I have a pyramid application which needs to deal with special characters in urls (like é è).

I had this exception when trying to visit this link:
http://localhost:6543/wiki/Cr%C3%A9er_un_compte (copy/paste from google chrome)
or maybe
http://localhost:6543/wiki/Créer_un_compte (as it looks like in the chrome url bar without copy/paste).

The traceback is at the end of this report. There is no error (the views returns the desired output) after disabling the debugtoolbar.

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 53316)
Traceback (most recent call last):
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 322, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.6/SocketServer.py", line 617, in __init__
    self.handle()
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 437, in handle_one_request
    self.wsgi_execute()
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/httpserver.py", line 287, in wsgi_execute
    self.wsgi_start_response)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid-1.2-py2.6.egg/pyramid/router.py", line 176, in __call__
    response = self.handle_request(request)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.3-py2.6.egg/pyramid_debugtoolbar/toolbar.py", line 150, in toolbar_tween
    toolbar.process_response(response)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.3-py2.6.egg/pyramid_debugtoolbar/toolbar.py", line 50, in process_response
    vars, request=request)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid-1.2-py2.6.egg/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid-1.2-py2.6.egg/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_jinja2-1.1-py2.6.egg/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/Jinja2-2.6-py2.6.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.3-py2.6.egg/pyramid_debugtoolbar/templates/toolbar.jinja2", line 62, in top-level template code
    {{ panel.content()|safe }}
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.3-py2.6.egg/pyramid_debugtoolbar/panels/headers.py", line 54, in content
    vars, self.request)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.3-py2.6.egg/pyramid_debugtoolbar/panels/__init__.py", line 24, in render
    return render(template_name, vars, request=request)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid-1.2-py2.6.egg/pyramid/renderers.py", line 69, in render
    return helper.render(value, None, request=request)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid-1.2-py2.6.egg/pyramid/renderers.py", line 418, in render
    result = renderer(value, system_values)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_jinja2-1.1-py2.6.egg/pyramid_jinja2/__init__.py", line 277, in __call__
    return self.template.render(system)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/Jinja2-2.6-py2.6.egg/jinja2/environment.py", line 894, in render
    return self.environment.handle_exception(exc_info, True)
  File "/home/adrien/virtualenvs/pyramid1_2/lib/python2.6/site-packages/pyramid_debugtoolbar-0.9.3-py2.6.egg/pyramid_debugtoolbar/panels/templates/headers.jinja2", line 13, in top-level template code
    <td>{{ value|escape }}</td>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 8: ordinal not in range(128)
----------------------------------------

Toolbar doesn't work at all in IE

As noted by mcdonc in comments on pull request 22. Would be nice to fix before Pyramid 1.2 launches.

I'll look into it the coming week.

REMOTE_ADDR used unconditionally

toolbar.py: 101
remote_addr = request.remote_addr

However, the wsgi spec does not actually define REMOTE_ADDR, and the system could be behind a proxy with X-FORWARDED-FOR headers. I know if at least one WSGI server that does not provide this.

Issue with conflicting jQuery modules

we use $(function() {}), aka ondomready quite extensively. After enabling debugtoolbar we found out that the global $ object did not contain necessary extensions anymore. This is probably caused by the debug toolbar fragment (https://github.com/Pylons/pyramid_debugtoolbar/blob/master/pyramid_debugtoolbar/templates/toolbar.jinja2#L11) injecting the scripts in separate elements;

Now, we have seen some browsers, e.g. Chrome, parsing the body scripts in order, the onDomReady event is sometimes (quite often actually) fired after the debug toolbar's jQuery has been loaded, but before $.noConflict() is called.

Thus, 2 things should be changed.

  1. $.noConflict(true) should be used to remove the jQuery variable too
  2. all these scripts should be catenated, and even then they should refer to $ only by closure.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.