[debug-toolbar/display_source_code] add links to files in tracebacks
authorLaurent Peuch <cortex@worlddomination.be>
Tue, 26 Nov 2019 20:26:58 +0100
changeset 12777 7c4216ed7497
parent 12776 3cbcbaead477
child 12778 8af81736f150
[debug-toolbar/display_source_code] add links to files in tracebacks
cubicweb/pyramid/debug_toolbar_templates/rql.dbtmako
cubicweb/pyramid/debug_toolbar_templates/sql.dbtmako
cubicweb/pyramid/debugtoolbar_panels.py
--- a/cubicweb/pyramid/debug_toolbar_templates/rql.dbtmako	Fri Sep 27 07:00:51 2019 +0200
+++ b/cubicweb/pyramid/debug_toolbar_templates/rql.dbtmako	Tue Nov 26 20:26:58 2019 +0100
@@ -47,7 +47,7 @@
             </tr>
             <tr style="display: none" id="stack-${i}">
                 <td colspan="7">
-                    <pre>${highlight(query["callstack"], "py3tb", linenos="inline") | n}</pre>
+                    <pre>${source_code_url_in_stack(highlight(query["callstack"], "py3tb", linenos="inline"), highlighted=has_pygments) | n}</pre>
                 </td>
             </tr>
             <tr style="display: none"></tr> <!-- css hack because of previous hidden tr for -stripped -->
--- a/cubicweb/pyramid/debug_toolbar_templates/sql.dbtmako	Fri Sep 27 07:00:51 2019 +0200
+++ b/cubicweb/pyramid/debug_toolbar_templates/sql.dbtmako	Tue Nov 26 20:26:58 2019 +0100
@@ -29,7 +29,7 @@
             </tr>
             <tr style="display: none" id="sql-stack-${i}">
                 <td colspan="6">
-                    <pre>${highlight(query["callstack"], "py3tb", linenos="inline") | n}</pre>
+                    <pre>${source_code_url_in_stack(highlight(query["callstack"], "py3tb", linenos="inline"), highlighted=has_pygments) | n}</pre>
                 </td>
             </tr>
             <tr style="display: none"></tr> <!-- css hack because of previous hidden tr for -stripped -->
--- a/cubicweb/pyramid/debugtoolbar_panels.py	Fri Sep 27 07:00:51 2019 +0200
+++ b/cubicweb/pyramid/debugtoolbar_panels.py	Tue Nov 26 20:26:58 2019 +0100
@@ -19,7 +19,8 @@
 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.misc.source_highlight import highlight_html, generate_css, has_pygments
+from cubicweb.pyramid.debug_source_code import source_code_url, source_code_url_in_stack
 
 
 class CubicWebDebugPanel(DebugPanel):
@@ -169,6 +170,8 @@
             'sql_queries': [],
             'highlight': highlight_html,
             'generate_css': generate_css,
+            'has_pygments': has_pygments,
+            'source_code_url_in_stack': source_code_url_in_stack,
         }
         subscribe_to_debug_channel("rql", self.collect_rql_queries)
         subscribe_to_debug_channel("sql", self.collect_sql_queries)
@@ -225,6 +228,8 @@
             'sql_queries': [],
             'highlight': highlight_html,
             'generate_css': generate_css,
+            'has_pygments': has_pygments,
+            'source_code_url_in_stack': source_code_url_in_stack,
         }
         subscribe_to_debug_channel("rql", self.collect_rql_queries)
         subscribe_to_debug_channel("sql", self.collect_sql_queries)