Use the util.format_fname function to format the context location

This commit is contained in:
mvantellingen
2011-02-13 21:20:00 +01:00
parent d7b98f9e77
commit 5eb0ddbc4e
2 changed files with 12 additions and 5 deletions

View File

@@ -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):

View File

@@ -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">