mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Replaced sanic.request.RequestParameters
This commit is contained in:
parent
1e0998ed2d
commit
979ae4f916
2 changed files with 15 additions and 3 deletions
|
|
@ -741,3 +741,16 @@ def format_bytes(bytes):
|
|||
return "{} {}".format(int(current), unit)
|
||||
else:
|
||||
return "{:.1f} {}".format(current, unit)
|
||||
|
||||
|
||||
class RequestParameters(dict):
|
||||
def get(self, name, default=None):
|
||||
"Return first value in the list, if available"
|
||||
try:
|
||||
return super().get(name)[0]
|
||||
except KeyError:
|
||||
return default
|
||||
|
||||
def getlist(self, name, default=None):
|
||||
"Return full list"
|
||||
return super().get(name, default)
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ import json
|
|||
|
||||
import jinja2
|
||||
from sanic.exceptions import NotFound
|
||||
from sanic.request import RequestParameters
|
||||
|
||||
from datasette.plugins import pm
|
||||
from datasette.utils import (
|
||||
CustomRow,
|
||||
QueryInterrupted,
|
||||
RequestParameters,
|
||||
append_querystring,
|
||||
compound_keys_after_sql,
|
||||
escape_sqlite,
|
||||
|
|
@ -219,8 +219,7 @@ class TableView(RowTableShared):
|
|||
if is_view:
|
||||
order_by = ""
|
||||
|
||||
# We roll our own query_string decoder because by default Sanic
|
||||
# drops anything with an empty value e.g. ?name__exact=
|
||||
# Ensure we don't drop anything with an empty value e.g. ?name__exact=
|
||||
args = RequestParameters(
|
||||
urllib.parse.parse_qs(request.query_string, keep_blank_values=True)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue