Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubicweb
Commits
fb97669efcaa
Commit
e712b698
authored
Oct 08, 2019
by
Laurent Peuch
Browse files
[debug-toolbar] add cw general panel with controller
Closes #17219897
parent
5c609202eb61
Changes
4
Hide whitespace changes
Inline
Side-by-side
cubicweb/debug.py
View file @
fb97669e
...
...
@@ -22,6 +22,7 @@ logger = getLogger('cubicweb')
SUBSCRIBERS
=
{
"controller"
:
[],
"rql"
:
[],
"sql"
:
[],
}
...
...
cubicweb/pyramid/bwcompat.py
View file @
fb97669e
...
...
@@ -34,7 +34,7 @@ import cubicweb
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 @@ class CubicWebPyramidHandler(object):
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
(
...
...
cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako
0 → 100644
View file @
fb97669e
<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>
cubicweb/pyramid/debugtoolbar_panels.py
View file @
fb97669e
...
...
@@ -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
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 @@ class RQLDebugPanel(DebugPanel):
def
includeme
(
config
):
config
.
add_debugtoolbar_panel
(
CubicWebDebugPanel
)
config
.
add_debugtoolbar_panel
(
RQLDebugPanel
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment