# HG changeset patch # User Laurent Peuch # Date 1570569079 -7200 # Node ID fb97669efcaa01d1fe749901c5dd69b30c80c121 # Parent 5c609202eb6121222f620af1e2ee17374ebbc638 [debug-toolbar] add cw general panel with controller Closes #17219897 diff -r 5c609202eb61 -r fb97669efcaa cubicweb/debug.py --- a/cubicweb/debug.py Mon Nov 18 12:41:44 2019 +0100 +++ b/cubicweb/debug.py Tue Oct 08 23:11:19 2019 +0200 @@ -22,6 +22,7 @@ SUBSCRIBERS = { + "controller": [], "rql": [], "sql": [], } diff -r 5c609202eb61 -r fb97669efcaa cubicweb/pyramid/bwcompat.py --- a/cubicweb/pyramid/bwcompat.py Mon Nov 18 12:41:44 2019 +0100 +++ b/cubicweb/pyramid/bwcompat.py Tue Oct 08 23:11:19 2019 +0200 @@ -34,7 +34,7 @@ import cubicweb.web from cubicweb.web.application import CubicWebPublisher - +from cubicweb.debug import emit_to_debug_channel from cubicweb.web import LogOut, PublishException from cubicweb.pyramid.core import cw_to_pyramid @@ -93,6 +93,13 @@ ctrlid, req.path, controller, inspect.getsourcefile(controller.__class__), inspect.getsourcelines(controller.__class__)[1]) + emit_to_debug_channel("controller", { + "kind": ctrlid, + "request": req, + "path": req.path, + "controller": controller, + "config": self.appli.repo.config, + }) except cubicweb.NoSelectableObject: log.warn("WARNING '%s' unauthorized request", req.path) raise httpexceptions.HTTPUnauthorized( diff -r 5c609202eb61 -r fb97669efcaa cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako Tue Oct 08 23:11:19 2019 +0200 @@ -0,0 +1,63 @@ +

Controller

+ + + + + + + + + + + + + + + + + + +
KindRequestPathController
${controller["kind"]}${controller["request"]}${controller["path"]}${controller["controller"]}
+ +

Configuration

+ + + + + + + + + + + + % for key, metadata in sorted(controller["config"].options, key=lambda x: x[0]): + % if hasattr(controller["config"].config, key.replace("-", "_")): + <% value = getattr(controller["config"].config, key.replace("-", "_")) %> + + + % if value != metadata["default"]: + + % else: + + % endif + + + + % endif + % endfor + +
KeyValueDefaultHelp
${key}${value}${value}${metadata["default"]}${metadata["help"]}
+ + + +

Useful links

+ + + diff -r 5c609202eb61 -r fb97669efcaa cubicweb/pyramid/debugtoolbar_panels.py --- a/cubicweb/pyramid/debugtoolbar_panels.py Mon Nov 18 12:41:44 2019 +0100 +++ b/cubicweb/pyramid/debugtoolbar_panels.py Tue Oct 08 23:11:19 2019 +0200 @@ -21,6 +21,39 @@ from cubicweb.misc.source_highlight import highlight_html, generate_css +class CubicWebDebugPanel(DebugPanel): + """ + CubicWeb general debug panel + """ + + """ + Excepted formats: + Controller: { + "kind": ctrlid, + "request": req, + "path": req.path, + "controller": controller, + } + """ + + name = 'CubicWeb' + nav_title = 'CubicWeb' + title = 'CubicWeb general panel' + + has_content = True + template = 'cubicweb.pyramid:debug_toolbar_templates/cw.dbtmako' + + def __init__(self, request): + self.data = {'controller': None} + subscribe_to_debug_channel("controller", self.collect_controller) + + def collect_controller(self, controller): + self.data["controller"] = controller + + def process_response(self, response): + unsubscribe_to_debug_channel("controller", self.collect_controller) + + class RQLDebugPanel(DebugPanel): """ CubicWeb RQL debug panel @@ -78,4 +111,5 @@ def includeme(config): + config.add_debugtoolbar_panel(CubicWebDebugPanel) config.add_debugtoolbar_panel(RQLDebugPanel)