Skip to content

Commit 4fb323f

Browse files
committed
htmldump fix
1 parent 09463ab commit 4fb323f

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

servicestack/reflection.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,15 +493,16 @@ def printtable(obj, headers=None):
493493
def htmllist(d: dict):
494494
sb: List[str] = ["<table><tbody>"]
495495
for k, v in d.items():
496-
sb.append(f"<tr><th>{_str(k)}</th><td>{_str(v)}</td></tr>")
496+
sb.append(f"<tr><th>{_str(k)}</th><td>{htmldump(v)}</td></tr>")
497497
sb.append("</tbody></table>")
498498
return ''.join(sb)
499499

500500
def htmldump(objs, headers=None):
501+
if is_builtin(type(objs)):
502+
return _str(objs)
503+
501504
map_rows = to_dict(objs)
502505
t = type(map_rows)
503-
if is_builtin(t):
504-
return _str(map_rows)
505506
if is_dict(t):
506507
return htmllist(map_rows)
507508

@@ -526,10 +527,10 @@ def htmldump(objs, headers=None):
526527
row = []
527528
for k in headers:
528529
val = item[k] if k in item else ""
529-
row.append(f"<td>{val}</td>")
530+
row.append(f"<td>{htmldump(val)}</td>")
530531
rows.append(''.join(row))
531532
else:
532-
rows.append(f"<td>{item}</td>")
533+
rows.append(f"<td>{htmldump(item)}</td>")
533534
rows.append("</tr>")
534535

535536
sb.append(''.join(rows))

tests/test_inspect.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def test_does_support_FindTechnologies(self):
4646
fields='id,name,vendorName,createdBy,viewCount,favCount'))
4747

4848
# printdump(response)
49-
printtable(response.results)
50-
printtable(response.results, headers=['id', 'name', 'vendor_name', 'view_count', 'fav_count'])
51-
printtable(to_dict(response.results, key_case=titlecase))
52-
printhtmldump(response.results)
53-
inspect_vars({"response": response})
49+
# printtable(response.results)
50+
# printtable(response.results, headers=['id', 'name', 'vendor_name', 'view_count', 'fav_count'])
51+
# printtable(to_dict(response.results, key_case=titlecase))
52+
printhtmldump(response)
53+
# inspect_vars({"response": response})

0 commit comments

Comments
 (0)