diff --git a/tgext/debugbar/sections/sqla.py b/tgext/debugbar/sections/sqla.py index 5096f4f..af330ae 100644 --- a/tgext/debugbar/sections/sqla.py +++ b/tgext/debugbar/sections/sqla.py @@ -19,7 +19,7 @@ def default(self, obj): return str(obj) else: return json.JSONEncoder.default(self, obj) -json_encoder = ExtendedJSONEncoder() +json_encoder = lambda x: json.dumps(x, cls=ExtendedJSONEncoder) import tg from tg import config, request, app_globals @@ -89,6 +89,9 @@ def title(self): return _('SQLAlchemy') def _gather_queries(self): + if "sqlalchemy.json_serializer" in config: + json_encoder = config["sqlalchemy.json_serializer"] + queries = getattr(request, 'tgdb_sqla_queries', []) if not queries: return [] @@ -98,7 +101,7 @@ def _gather_queries(self): is_select = query['statement'].strip().lower().startswith('select') params = '' try: - params = json_encoder.encode(query['parameters']) + params = json_encoder(query['parameters']) except TypeError: return 'Unable to serialize parameters of the query'