17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
17 # with CubicWeb. If not, see <http://www.gnu.org/licenses/>. |
18 |
18 |
19 from pyramid_debugtoolbar.panels import DebugPanel |
19 from pyramid_debugtoolbar.panels import DebugPanel |
20 from cubicweb.debug import subscribe_to_debug_channel, unsubscribe_to_debug_channel |
20 from cubicweb.debug import subscribe_to_debug_channel, unsubscribe_to_debug_channel |
21 from cubicweb.misc.source_highlight import highlight_html, generate_css |
21 from cubicweb.misc.source_highlight import highlight_html, generate_css |
|
22 |
|
23 |
|
24 class CubicWebDebugPanel(DebugPanel): |
|
25 """ |
|
26 CubicWeb general debug panel |
|
27 """ |
|
28 |
|
29 """ |
|
30 Excepted formats: |
|
31 Controller: { |
|
32 "kind": ctrlid, |
|
33 "request": req, |
|
34 "path": req.path, |
|
35 "controller": controller, |
|
36 } |
|
37 """ |
|
38 |
|
39 name = 'CubicWeb' |
|
40 nav_title = 'CubicWeb' |
|
41 title = 'CubicWeb general panel' |
|
42 |
|
43 has_content = True |
|
44 template = 'cubicweb.pyramid:debug_toolbar_templates/cw.dbtmako' |
|
45 |
|
46 def __init__(self, request): |
|
47 self.data = {'controller': None} |
|
48 subscribe_to_debug_channel("controller", self.collect_controller) |
|
49 |
|
50 def collect_controller(self, controller): |
|
51 self.data["controller"] = controller |
|
52 |
|
53 def process_response(self, response): |
|
54 unsubscribe_to_debug_channel("controller", self.collect_controller) |
22 |
55 |
23 |
56 |
24 class RQLDebugPanel(DebugPanel): |
57 class RQLDebugPanel(DebugPanel): |
25 """ |
58 """ |
26 CubicWeb RQL debug panel |
59 CubicWeb RQL debug panel |
76 unsubscribe_to_debug_channel("rql", self.collect_rql_queries) |
109 unsubscribe_to_debug_channel("rql", self.collect_rql_queries) |
77 unsubscribe_to_debug_channel("sql", self.collect_sql_queries) |
110 unsubscribe_to_debug_channel("sql", self.collect_sql_queries) |
78 |
111 |
79 |
112 |
80 def includeme(config): |
113 def includeme(config): |
|
114 config.add_debugtoolbar_panel(CubicWebDebugPanel) |
81 config.add_debugtoolbar_panel(RQLDebugPanel) |
115 config.add_debugtoolbar_panel(RQLDebugPanel) |