Commit e712b698 authored by Laurent Peuch's avatar Laurent Peuch
Browse files

[debug-toolbar] add cw general panel with controller

Closes #17219897
parent 5c609202eb61
...@@ -22,6 +22,7 @@ logger = getLogger('cubicweb') ...@@ -22,6 +22,7 @@ logger = getLogger('cubicweb')
SUBSCRIBERS = { SUBSCRIBERS = {
"controller": [],
"rql": [], "rql": [],
"sql": [], "sql": [],
} }
......
...@@ -34,7 +34,7 @@ import cubicweb ...@@ -34,7 +34,7 @@ import cubicweb
import cubicweb.web import cubicweb.web
from cubicweb.web.application import CubicWebPublisher from cubicweb.web.application import CubicWebPublisher
from cubicweb.debug import emit_to_debug_channel
from cubicweb.web import LogOut, PublishException from cubicweb.web import LogOut, PublishException
from cubicweb.pyramid.core import cw_to_pyramid from cubicweb.pyramid.core import cw_to_pyramid
...@@ -93,6 +93,13 @@ class CubicWebPyramidHandler(object): ...@@ -93,6 +93,13 @@ class CubicWebPyramidHandler(object):
ctrlid, req.path, controller, ctrlid, req.path, controller,
inspect.getsourcefile(controller.__class__), inspect.getsourcefile(controller.__class__),
inspect.getsourcelines(controller.__class__)[1]) 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: except cubicweb.NoSelectableObject:
log.warn("WARNING '%s' unauthorized request", req.path) log.warn("WARNING '%s' unauthorized request", req.path)
raise httpexceptions.HTTPUnauthorized( raise httpexceptions.HTTPUnauthorized(
......
<h3>Controller</h3>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Kind</th>
<th>Request</th>
<th>Path</th>
<th>Controller</th>
</tr>
</thead>
<tbody>
<tr>
<td>${controller["kind"]}</td>
<td>${controller["request"]}</td>
<td>${controller["path"]}</td>
<td>${controller["controller"]}</td>
</tr>
</tbody>
</table>
<h3>Configuration</h3>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>Key</th>
<th>Value</th>
<th>Default</th>
<th>Help</th>
</tr>
</thead>
<tbody>
% 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("-", "_")) %>
<tr>
<td>${key}</td>
% if value != metadata["default"]:
<td><b>${value}</b></td>
% else:
<td>${value}</td>
% endif
<td>${metadata["default"]}</td>
<td>${metadata["help"]}</td>
</tr>
% endif
% endfor
</tbody>
</table>
<h3>Useful links</h3>
<!-- link on the default home as an admin -->
<ul>
<li><a href="/siteconfig">site configuration</a></li>
<li><a href="/schema">data model schema</a></li>
<li><a href="/cwuser">users and groups</a></li>
<li><a href="/cwsource">data sources</a></li>
<li><a href="/siteinfo">Site information</a></li>
</ul>
...@@ -21,6 +21,39 @@ from cubicweb.debug import subscribe_to_debug_channel, unsubscribe_to_debug_chan ...@@ -21,6 +21,39 @@ from cubicweb.debug import subscribe_to_debug_channel, unsubscribe_to_debug_chan
from cubicweb.misc.source_highlight import highlight_html, generate_css 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): class RQLDebugPanel(DebugPanel):
""" """
CubicWeb RQL debug panel CubicWeb RQL debug panel
...@@ -78,4 +111,5 @@ class RQLDebugPanel(DebugPanel): ...@@ -78,4 +111,5 @@ class RQLDebugPanel(DebugPanel):
def includeme(config): def includeme(config):
config.add_debugtoolbar_panel(CubicWebDebugPanel)
config.add_debugtoolbar_panel(RQLDebugPanel) config.add_debugtoolbar_panel(RQLDebugPanel)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment