debug_toolbar.core.toolbar

Main debug toolbar manager class.

Classes

DebugToolbar([config])

Main debug toolbar manager.

class debug_toolbar.core.toolbar.DebugToolbar(config=None)[source]

Main debug toolbar manager.

Responsible for: - Panel lifecycle management (create, enable/disable, destroy) - Request context initialization - Data collection orchestration - Toolbar rendering coordination

__init__(config=None)[source]

Initialize the debug toolbar.

Parameters:

config (DebugToolbarConfig | None) – Configuration options. Uses defaults if not provided.

property config: DebugToolbarConfig

Get the toolbar configuration.

property storage: ToolbarStorage

Get the toolbar storage.

property panels: list[Panel]

Get all panel instances.

property enabled_panels: list[Panel]

Get only enabled panel instances.

get_panel(panel_id)[source]

Get a panel by its ID.

Parameters:

panel_id (str) – The panel’s unique identifier.

Return type:

Panel | None

Returns:

The panel instance, or None if not found.

async process_request()[source]

Start processing a request.

Creates a new request context and notifies all panels.

Return type:

RequestContext

Returns:

The new request context.

async process_response(context=None)[source]

Finish processing a request.

Collects stats from all panels and stores in history.

Parameters:

context (RequestContext | None) – The request context. Uses current context if not provided.

Return type:

None

get_server_timing_header(context=None)[source]

Generate Server-Timing header value.

Parameters:

context (RequestContext | None) – The request context. Uses current context if not provided.

Return type:

str

Returns:

Server-Timing header value string.

get_toolbar_data(context=None)[source]

Get all data for rendering the toolbar.

Parameters:

context (RequestContext | None) – The request context. Uses current context if not provided.

Return type:

dict[str, Any]

Returns:

Dictionary with toolbar data including all panel stats.