xtr_web_profiler.bundle ¶
The xtr-dependency-injection bundle for xtr-web-profiler.
WEB_DEBUG_TOOLBAR_PRIORITY
module-attribute
¶
Where the toolbar middleware sits: outside the request lifecycle's, at its default 0.
It must stay outside — above HttpKernelConfig.middleware_priority — to
see the X-Debug-Token the lifecycle's listeners put on a response.
WebDebugToolbarMiddlewareFactory ¶
WebDebugToolbarMiddlewareFactory(config: WebProfilerConfig, manager: TemplateManager, csp: ContentSecurityPolicyHandler)
Wraps a downstream app in the toolbar middleware; tagged for the kernel's stack.
Hand every middleware built config, manager and csp.
WebProfilerBundle ¶
Bases: Bundle[WebProfilerConfig]
Registers the toolbar middleware, the profiler's pages and their route resources.
prepend_extension ¶
Turn the http kernel's profiler on, wherever this bundle is listed.
An application turning it off again — with a transform of the http kernel's configuration — keeps the pages, which then answer 404.
load_extension ¶
load_extension(config: WebProfilerConfig, services: ServiceConfigurator, builder: ContainerBuilder) -> None
Register the pages, the template environment and the toolbar middleware.
Warns when the kernel runs in production: every profile holds every request's headers, cookies and state, readable by whoever reaches the pages.
WebProfilerConfig
dataclass
¶
WebProfilerConfig(toolbar: bool = True, ajax_replace: bool = False, intercept_redirects: bool = False, excluded_ajax_paths: str = '^/(_wdt|_profiler)', file_link_format: str | None = None)
What an application may change about the toolbar and the profiler pages.
Attributes:
-
toolbar(bool) –Whether HTML pages get the debug toolbar.
-
ajax_replace(bool) –Whether a background request whose response names a profile reloads the toolbar with that profile.
-
intercept_redirects(bool) –Whether a redirect answering a page is shown as a page of its own — with the toolbar, and a link to follow it — so the request that redirected can be inspected before it is left.
-
excluded_ajax_paths(str) –A regular expression; background requests to a matching path are left out of the toolbar's list.
-
file_link_format(str | None) –How a file and line open in an editor —
{file}is the file,{line}the line, as in"pycharm://open?file={file}&line={line}"or"vscode://file/{file}:{line}".Noneopens them in the profiler's own source view.
Raises:
-
InvalidArgumentError–When
excluded_ajax_pathsis not a regular expression, orfile_link_formatdoes not name the file.