-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Link to BLOB downloads #2
Comments
I should use |
I can ship this against the new 0.51a1 release. |
This will be easier after the next Datasette release since it adds the |
Blocked on that release. |
https://github.com/simonw/datasette/releases/tag/0.62 is out, unblocking this. |
Here's the code in Datasette core that renders the display_value = markupsafe.Markup(
'<a class="blob-download" href="{}"{}><Binary: {:,} byte{}></a>'.format(
datasette.urls.row_blob(
database_name,
table_name,
path_from_row_pks(row, pks, not pks),
column,
),
' title="{}"'.format(formatted)
if "bytes" not in formatted
else "",
len(value),
"" if len(value) == 1 else "s",
)
) |
I need pks = await db.primary_keys(table_name) But I really don't want to run that for every single time the |
I'm tempted to add One catch there though: it's not available for arbitrary database queries, but those need to be supported by this plugin too - like this: https://latest.datasette.io/_memory?sql=select+X%2753514C697465%27 Here's how that works: https://github.com/simonw/datasette/blob/5aa359b86907d11b3ee601510775a85a90224da8/datasette/views/database.py#L409-L430 elif isinstance(display_value, bytes):
blob_url = path_with_format(
request=request,
format="blob",
extra_qs={
"_blob_column": column,
"_blob_hash": hashlib.sha256(
display_value
).hexdigest(),
},
)
formatted = format_bytes(len(value))
display_value = markupsafe.Markup(
'<a class="blob-download" href="{}"{}><Binary: {:,} byte{}></a>'.format(
blob_url,
' title="{}"'.format(formatted)
if "bytes" not in formatted
else "",
len(value),
"" if len(value) == 1 else "s",
)
) |
This code is all complex enough that I think I need to refactor it in Datasette core so I can reuse that here, rather than re-implementing some pretty gnarly Datasette internals just for this plugin. |
As added to Datasette in simonw/datasette#1036
Blocked awaiting release of Datasette 0.51.
The text was updated successfully, but these errors were encountered: