[debug-toolbar] link to source code of all objects/classes
authorLaurent Peuch <cortex@worlddomination.be>
Fri, 27 Sep 2019 07:00:51 +0200
changeset 12776 3cbcbaead477
parent 12775 38f22b8b4459
child 12777 7c4216ed7497
[debug-toolbar] link to source code of all objects/classes Closes #17256791
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
--- 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
@@ -12,9 +12,9 @@
     <tbody>
         <tr>
             <td>${controller["kind"]}</td>
-            <td>${controller["request"]}</td>
+            <td>${controller["request"]} ${source_code_url(controller["request"]) | n}</td>
             <td>${controller["path"]}</td>
-            <td>${controller["controller"]}</td>
+            <td>${controller["controller"]} ${source_code_url(controller["controller"]) | n}</td>
         </tr>
     </tbody>
 </table>
--- 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
@@ -30,7 +30,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/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
@@ -17,6 +17,7 @@
 # with CubicWeb.  If not, see <http://www.gnu.org/licenses/>.
 
 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
 
@@ -44,7 +45,11 @@
     template = 'cubicweb.pyramid:debug_toolbar_templates/cw.dbtmako'
 
     def __init__(self, request):
-        self.data = {'controller': None}
+        self.data = {
+            'controller': None,
+            'source_code_url': source_code_url,
+        }
+
         subscribe_to_debug_channel("controller", self.collect_controller)
 
     def collect_controller(self, controller):
@@ -73,6 +78,7 @@
             'vreg': None,
             'highlight': highlight_html,
             'generate_css': generate_css,
+            'source_code_url': source_code_url,
         }
 
         subscribe_to_debug_channel("vreg", self.collect_vreg)
@@ -120,7 +126,10 @@
     template = 'cubicweb.pyramid:debug_toolbar_templates/registry.dbtmako'
 
     def __init__(self, request):
-        self.data = {'vreg': None}
+        self.data = {
+            'vreg': None,
+            'source_code_url': source_code_url,
+        }
         subscribe_to_debug_channel("vreg", self.collect_vreg)
 
     def collect_vreg(self, message):