mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Stop using firstresult=True on render_cell, refs #1425
See https://github.com/simonw/datasette/issues/1425#issuecomment-894883664
This commit is contained in:
parent
f3c9edb376
commit
a390bdf9ce
3 changed files with 18 additions and 10 deletions
|
|
@ -59,7 +59,7 @@ def publish_subcommand(publish):
|
||||||
"""Subcommands for 'datasette publish'"""
|
"""Subcommands for 'datasette publish'"""
|
||||||
|
|
||||||
|
|
||||||
@hookspec(firstresult=True)
|
@hookspec
|
||||||
def render_cell(value, column, table, database, datasette):
|
def render_cell(value, column, table, database, datasette):
|
||||||
"""Customize rendering of HTML table cell values"""
|
"""Customize rendering of HTML table cell values"""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -354,16 +354,20 @@ class QueryView(DataView):
|
||||||
display_value = value
|
display_value = value
|
||||||
# Let the plugins have a go
|
# Let the plugins have a go
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
plugin_value = pm.hook.render_cell(
|
plugin_display_value = None
|
||||||
|
for candidate in pm.hook.render_cell(
|
||||||
value=value,
|
value=value,
|
||||||
column=column,
|
column=column,
|
||||||
table=None,
|
table=None,
|
||||||
database=database,
|
database=database,
|
||||||
datasette=self.ds,
|
datasette=self.ds,
|
||||||
)
|
):
|
||||||
plugin_value = await await_me_maybe(plugin_value)
|
candidate = await await_me_maybe(candidate)
|
||||||
if plugin_value is not None:
|
if candidate is not None:
|
||||||
display_value = plugin_value
|
plugin_display_value = candidate
|
||||||
|
break
|
||||||
|
if plugin_display_value is not None:
|
||||||
|
display_value = plugin_display_value
|
||||||
else:
|
else:
|
||||||
if value in ("", None):
|
if value in ("", None):
|
||||||
display_value = Markup(" ")
|
display_value = Markup(" ")
|
||||||
|
|
|
||||||
|
|
@ -191,15 +191,19 @@ class RowTableShared(DataView):
|
||||||
|
|
||||||
# First let the plugins have a go
|
# First let the plugins have a go
|
||||||
# pylint: disable=no-member
|
# pylint: disable=no-member
|
||||||
plugin_display_value = pm.hook.render_cell(
|
plugin_display_value = None
|
||||||
|
for candidate in pm.hook.render_cell(
|
||||||
value=value,
|
value=value,
|
||||||
column=column,
|
column=column,
|
||||||
table=table,
|
table=table,
|
||||||
database=database,
|
database=database,
|
||||||
datasette=self.ds,
|
datasette=self.ds,
|
||||||
)
|
):
|
||||||
plugin_display_value = await await_me_maybe(plugin_display_value)
|
candidate = await await_me_maybe(candidate)
|
||||||
if plugin_display_value is not None:
|
if candidate is not None:
|
||||||
|
plugin_display_value = candidate
|
||||||
|
break
|
||||||
|
if plugin_display_value:
|
||||||
display_value = plugin_display_value
|
display_value = plugin_display_value
|
||||||
elif isinstance(value, bytes):
|
elif isinstance(value, bytes):
|
||||||
display_value = markupsafe.Markup(
|
display_value = markupsafe.Markup(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue