mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2026-01-01 19:19:33 -06:00
Use the util.format_fname function to format the context location
This commit is contained in:
@@ -13,6 +13,8 @@ except ImportError:
|
||||
HAVE_PYGMENTS = False
|
||||
|
||||
from flaskext.debugtoolbar.panels import DebugPanel
|
||||
from flaskext.debugtoolbar.utils import format_fname
|
||||
|
||||
_ = lambda x: x
|
||||
|
||||
class SQLAlchemyDebugPanel(DebugPanel):
|
||||
@@ -51,10 +53,15 @@ class SQLAlchemyDebugPanel(DebugPanel):
|
||||
|
||||
def content(self):
|
||||
queries = get_debug_queries()
|
||||
data = []
|
||||
for query in queries:
|
||||
query.sql = self._format_sql(query.statement, query.parameters)
|
||||
|
||||
return self.render('panels/sqlalchemy.html', { 'queries': queries})
|
||||
data.append({
|
||||
'duration': query.duration,
|
||||
'sql': self._format_sql(query.statement, query.parameters),
|
||||
'context_long': query.context,
|
||||
'context': format_fname(query.context)
|
||||
})
|
||||
return self.render('panels/sqlalchemy.html', { 'queries': data})
|
||||
|
||||
|
||||
def _format_sql(self, query, args):
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<tbody>
|
||||
{% for query in queries %}
|
||||
<tr class="{{ loop.cycle('flDebugOdd' 'flDebugEven') }}">
|
||||
<td>{{ query.duration }}</td>
|
||||
<td>{{ '%.4f'|format(query.duration) }}</td>
|
||||
<td>
|
||||
{#
|
||||
{% if query.params %}
|
||||
@@ -24,7 +24,7 @@
|
||||
{% endif %}
|
||||
#}
|
||||
</td>
|
||||
<td>
|
||||
<td title="{{ query.context_long }}">
|
||||
{{ query.context }}
|
||||
</td>
|
||||
<td class="syntax">
|
||||
|
||||
Reference in New Issue
Block a user