Pyramid Debugtoolbar
Pyramid Debugtoolbar is a package that provides an interactive HTML debugger for Pyramid application development. It offers various panels to inspect requests, responses, SQL queries, templates, and more, significantly aiding in development and debugging. The library is actively maintained, with its latest version 4.12.1 released in February 2024.
Warnings
- breaking Older versions of `pyramid_debugtoolbar` (prior to 1.0.8) are not compatible with Pyramid versions 1.5a2 and newer, due to changes in Pyramid's core. Ensure you upgrade `pyramid_debugtoolbar` if you are using a newer Pyramid version.
- breaking The debug toolbar should NEVER be enabled in a production environment. It allows arbitrary code execution from semi-trusted sources, posing a severe security risk.
- gotcha The toolbar can consume significant memory, especially during long-running tasks, as it captures a large amount of application state for introspection. This can lead to high memory usage or Out-Of-Memory (OOM) errors.
- gotcha When running a Pyramid application over HTTPS, `pyramid_debugtoolbar` might generate HTTP links for its static assets (CSS, JavaScript), leading to mixed content warnings in browsers and potentially broken toolbar functionality.
Install
-
pip install pyramid-debugtoolbar
Imports
- pyramid_debugtoolbar
config.include('pyramid_debugtoolbar')
Quickstart
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
return Response('Hello, Debugtoolbar!')
if __name__ == '__main__':
with Configurator() as config:
# Include the debug toolbar
config.include('pyramid_debugtoolbar')
config.add_route('home', '/')
config.add_view(hello_world, route_name='home')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 6543, app)
print('Serving on http://localhost:6543 (debug toolbar enabled)')
server.serve_forever()