.blob output renderer

* _blob_hash= checking plus refactored to use new BadRequest class, refs #1050
* Replace BlobView with new .blob renderer, closes #1050
* .blob downloads on arbitrary queries, closes #1051
This commit is contained in:
Simon Willison 2020-10-29 15:01:38 -07:00 committed by GitHub
commit 78b3eeaad9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 165 additions and 121 deletions

View file

@ -26,6 +26,7 @@ from datasette.utils.asgi import (
Forbidden,
NotFound,
Response,
BadRequest,
)
ureg = pint.UnitRegistry()
@ -260,9 +261,9 @@ class DataView(BaseView):
if stream:
# Some quick sanity checks
if not self.ds.config("allow_csv_stream"):
raise DatasetteError("CSV streaming is disabled", status=400)
raise BadRequest("CSV streaming is disabled")
if request.args.get("_next"):
raise DatasetteError("_next not allowed for CSV streaming", status=400)
raise BadRequest("_next not allowed for CSV streaming")
kwargs["_size"] = "max"
# Fetch the first page
try: