[pyramid_debugtoolbar] link to source code of all objects/classes draft
authorLaurent Peuch <cortex@worlddomination.be>
Fri, 27 Sep 2019 07:00:51 +0200
changeset 13436 5b957bd567da
parent 13435 d0639b416403
child 13437 1115ff750878
[pyramid_debugtoolbar] link to source code of all objects/classes
cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako
cubicweb/pyramid/debug_toolbar_templates/hooks.dbtmako
cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako
cubicweb/pyramid/debug_toolbar_templates/registry_decisions.dbtmako
cubicweb/pyramid/debug_toolbar_templates/rendering.dbtmako
cubicweb/pyramid/debugtoolbar_panels.py
--- a/cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako	Fri Sep 27 06:59:48 2019 +0200
+++ b/cubicweb/pyramid/debug_toolbar_templates/cw.dbtmako	Fri Sep 27 07:00:51 2019 +0200
@@ -13,9 +13,9 @@
         % for c in controller:
         <tr>
             <td>${c["kind"]}</td>
-            <td>${c["request"]}</td>
+            <td>${c["request"]} ${source_code_url(c["request"]) | n}</td>
             <td>${c["path"]}</td>
-            <td>${c["controller"]}</td>
+            <td>${c["controller"]} ${source_code_url(c["controller"]) | n}</td>
         </tr>
         % endfor
     </tbody>
--- a/cubicweb/pyramid/debug_toolbar_templates/hooks.dbtmako	Fri Sep 27 06:59:48 2019 +0200
+++ b/cubicweb/pyramid/debug_toolbar_templates/hooks.dbtmako	Fri Sep 27 07:00:51 2019 +0200
@@ -18,7 +18,7 @@
                 <td class="table-col-2">${hook["datetime"].strftime("%X")}</td>
                 <td class="table-col-3">${hook["event"]}</td>
                 <td class="table-col-4">
-                    ${hook["hook"].__class__.__name__}
+                    ${hook["hook"].__class__.__name__} ${source_code_url(hook["hook"]) | n}
                     <ul>
                         <li>object: ${highlight(hook["hook"], "python") | n}</li>
                         <li>entity: <span title="${hook['entity_file']}:${hook['entity_line']}">
--- a/cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako	Fri Sep 27 06:59:48 2019 +0200
+++ b/cubicweb/pyramid/debug_toolbar_templates/registry.dbtmako	Fri Sep 27 07:00:51 2019 +0200
@@ -34,6 +34,7 @@
                                     % else:
                                     ${value}
                                     % endif
+                                    ${source_code_url(value) | n}
                                     <ul>
                                         % if hasattr(value, "cw_etype"):
                                         <li>regid: '${value.cw_etype}'</li>
--- a/cubicweb/pyramid/debug_toolbar_templates/registry_decisions.dbtmako	Fri Sep 27 06:59:48 2019 +0200
+++ b/cubicweb/pyramid/debug_toolbar_templates/registry_decisions.dbtmako	Fri Sep 27 07:00:51 2019 +0200
@@ -14,7 +14,7 @@
     <tr></tr>
 % for registry_decision in registry_decisions:
     <tr>
-        <td colspan="2"><b>${repr(registry_decision["key"])} -&gt; ${render_object(registry_decision["winner"])}</b></td>
+        <td colspan="2"><b>${repr(registry_decision["key"])} -&gt; ${render_object(registry_decision["winner"])} ${source_code_url(registry_decision["winner"]) | n}</b></td>
     </tr>
     <tr>
         <td>
@@ -33,7 +33,7 @@
             <ul>
                 % for obj in registry_decision["all_objects"]:
                 <li>
-                    ${obj["score"]}: ${render_object(obj["object"])}
+                    ${obj["score"]}: ${render_object(obj["object"])} ${source_code_url(obj["object"]) | n}
                 </li>
                 % endfor
             </ul>
--- a/cubicweb/pyramid/debug_toolbar_templates/rendering.dbtmako	Fri Sep 27 06:59:48 2019 +0200
+++ b/cubicweb/pyramid/debug_toolbar_templates/rendering.dbtmako	Fri Sep 27 07:00:51 2019 +0200
@@ -4,7 +4,7 @@
             <span class="vid" title="__vid">"${rc["vid"]}"</span>
             <span class="red">-&gt;</span>
         % endif
-        <span class="${rc["kind"]}">${rc["object"].__class__.__name__} [${rc["kind"].title()}]</span>
+        <span class="${rc["kind"]}">${rc["object"].__class__.__name__} [${rc["kind"].title()}] ${source_code_url(rc["object"]) | n}</span>
     </div>
 
     <ul class="tree">
--- a/cubicweb/pyramid/debugtoolbar_panels.py	Fri Sep 27 06:59:48 2019 +0200
+++ b/cubicweb/pyramid/debugtoolbar_panels.py	Fri Sep 27 07:00:51 2019 +0200
@@ -19,8 +19,10 @@
 from collections import defaultdict
 
 from pyramid_debugtoolbar.panels import DebugPanel
+
 from cubicweb.debug import subscribe_to_debug_channel, unsubscribe_to_debug_channel
 from cubicweb.misc.source_highlight import highlight_html, generate_css
+from cubicweb.pyramid.debug_source_code import source_code_url, source_code_url_in_stack
 
 
 class CubicWebDebugPanel(DebugPanel):
@@ -66,6 +68,7 @@
             'controller': self.controller[:],
             'highlight': highlight_html,
             'generate_css': generate_css,
+            'source_code_url': source_code_url,
         }
         self.controller = []
 
@@ -213,6 +216,7 @@
             'rendering_classes': self.rendering_tree(self.rendering_classes[:]),
             'highlight': highlight_html,
             'generate_css': generate_css,
+            'source_code_url': source_code_url,
         }
         self.rendering_classes = []
 
@@ -281,6 +285,7 @@
             'vreg': self.vreg[0]["vreg"] if self.vreg else None,
             'highlight': highlight_html,
             'generate_css': generate_css,
+            'source_code_url': source_code_url,
         }
 
         self.link_registry_to_their_key()
@@ -322,6 +327,7 @@
             'vreg': self.vreg[0]["vreg"] if self.vreg else None,
             'highlight': highlight_html,
             'generate_css': generate_css,
+            'source_code_url': source_code_url,
         }
         self.rendering_classes = []
 
@@ -539,6 +545,7 @@
             'hooks': hooks_events[:],
             'generate_css': generate_css,
             'highlight': highlight_html,
+            'source_code_url': source_code_url,
         }
         # self.hooks_events = []