[debug-toolbar] link to source code of all objects/classes

Closes #17256791

authorLaurent Peuch <cortex@worlddomination.be>
changeset3cbcbaead477
branchdefault
phasepublic
hiddenno
parent revision#38f22b8b4459 [debug-toolbar/display_source_code] add a function to add links to source file in traceback
child revision#7c4216ed7497 [debug-toolbar/display_source_code] add links to files in tracebacks
files modified by this revision
cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako
cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako
cubicweb/pyramid/debug_toolbar_templates/registry_decisions.dbtmako
cubicweb/pyramid/debugtoolbar_panels.py
# HG changeset patch
# User Laurent Peuch <cortex@worlddomination.be>
# Date 1569560451 -7200
# Fri Sep 27 07:00:51 2019 +0200
# Node ID 3cbcbaead477397405a59170c75577b58ffc086f
# Parent 38f22b8b445968dea3da29d28054779553c2583d
[debug-toolbar] link to source code of all objects/classes

Closes #17256791

diff --git a/cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako b/cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako
@@ -10,13 +10,13 @@
1          </tr>
2      </thead>
3      <tbody>
4          <tr>
5              <td>${controller["kind"]}</td>
6 -            <td>${controller["request"]}</td>
7 +            <td>${controller["request"]} ${source_code_url(controller["request"]) | n}</td>
8              <td>${controller["path"]}</td>
9 -            <td>${controller["controller"]}</td>
10 +            <td>${controller["controller"]} ${source_code_url(controller["controller"]) | n}</td>
11          </tr>
12      </tbody>
13  </table>
14 
15  <h3>Configuration</h3>
diff --git a/cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako b/cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako
@@ -28,11 +28,11 @@
16                                      % if isinstance(value, type):
17                                      ${value.__module__}.${value.__name__}
18                                      % else:
19                                      ${value}
20                                      % endif
21 -
22 +                                    ${source_code_url(value) | n}
23                                      <ul>
24                                          % if hasattr(value, "cw_etype"):
25                                          <li>regid: '${value.cw_etype}'</li>
26                                          % elif hasattr(value, "__regid__"):
27                                          <li>regid: '${value.__regid__}'</li>
diff --git a/cubicweb/pyramid/debug_toolbar_templates/registry_decisions.dbtmako b/cubicweb/pyramid/debug_toolbar_templates/registry_decisions.dbtmako
@@ -12,11 +12,11 @@
28          <th>Decision</th>
29      </tr>
30      <tr></tr>
31  % for registry_decision in registry_decisions:
32      <tr>
33 -        <td colspan="2"><b>${repr(registry_decision["key"])} -&gt; ${render_object(registry_decision["winner"])}</b></td>
34 +        <td colspan="2"><b>${repr(registry_decision["key"])} -&gt; ${render_object(registry_decision["winner"])} ${source_code_url(registry_decision["winner"]) | n}</b></td>
35      </tr>
36      <tr>
37          <td>
38              <p>End score: ${registry_decision["end_score"]}</p>
39              <div class="highlight-inline">args: ${highlight(registry_decision["args"], "html") | n}</div>
@@ -31,11 +31,11 @@
40 
41          <td>
42              <ul>
43                  % for obj in registry_decision["all_objects"]:
44                  <li>
45 -                    ${obj["score"]}: ${render_object(obj["object"])}
46 +                    ${obj["score"]}: ${render_object(obj["object"])} ${source_code_url(obj["object"]) | n}
47                  </li>
48                  % endfor
49              </ul>
50          </td>
51 
diff --git a/cubicweb/pyramid/debugtoolbar_panels.py b/cubicweb/pyramid/debugtoolbar_panels.py
@@ -15,10 +15,11 @@
52  #
53  # You should have received a copy of the GNU Lesser General Public License along
54  # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
55 
56  from pyramid_debugtoolbar.panels import DebugPanel
57 +
58  from cubicweb.debug import subscribe_to_debug_channel, unsubscribe_to_debug_channel
59  from cubicweb.misc.source_highlight import highlight_html, generate_css
60 
61 
62  class CubicWebDebugPanel(DebugPanel):
@@ -42,11 +43,15 @@
63 
64      has_content = True
65      template = 'cubicweb.pyramid:debug_toolbar_templates/cw.dbtmako'
66 
67      def __init__(self, request):
68 -        self.data = {'controller': None}
69 +        self.data = {
70 +            'controller': None,
71 +            'source_code_url': source_code_url,
72 +        }
73 +
74          subscribe_to_debug_channel("controller", self.collect_controller)
75 
76      def collect_controller(self, controller):
77          self.data["controller"] = controller
78 
@@ -71,10 +76,11 @@
79          self.data = {
80              'registry_decisions': [],
81              'vreg': None,
82              'highlight': highlight_html,
83              'generate_css': generate_css,
84 +            'source_code_url': source_code_url,
85          }
86 
87          subscribe_to_debug_channel("vreg", self.collect_vreg)
88          subscribe_to_debug_channel("registry_decisions", self.collect_registry_decisions)
89 
@@ -118,11 +124,14 @@
90 
91      has_content = True
92      template = 'cubicweb.pyramid:debug_toolbar_templates/registry.dbtmako'
93 
94      def __init__(self, request):
95 -        self.data = {'vreg': None}
96 +        self.data = {
97 +            'vreg': None,
98 +            'source_code_url': source_code_url,
99 +        }
100          subscribe_to_debug_channel("vreg", self.collect_vreg)
101 
102      def collect_vreg(self, message):
103          self.data["vreg"] = message["vreg"]
104