kopia lustrzana https://github.com/simonw/datasette
Stop using .raw_args, deprecate and undocument it - refs #706
rodzic
6d7cb02f00
commit
50652f474b
|
@ -65,6 +65,7 @@ class Request:
|
|||
|
||||
@property
|
||||
def raw_args(self):
|
||||
# Deprecated, undocumented - may be removed in Datasette 1.0
|
||||
return {key: value[0] for key, value in self.args.items()}
|
||||
|
||||
async def post_vars(self):
|
||||
|
|
|
@ -24,7 +24,7 @@ class DatabaseView(DataView):
|
|||
if request.args.get("sql"):
|
||||
if not self.ds.config("allow_sql"):
|
||||
raise DatasetteError("sql= is not allowed", status=400)
|
||||
sql = request.raw_args.pop("sql")
|
||||
sql = request.args.get("sql")
|
||||
validate_sql_select(sql)
|
||||
return await QueryView(self.ds).data(
|
||||
request, database, hash, sql, _size=_size, metadata=metadata
|
||||
|
@ -107,7 +107,7 @@ class QueryView(DataView):
|
|||
metadata=None,
|
||||
_size=None,
|
||||
):
|
||||
params = request.raw_args
|
||||
params = {key: request.args.get(key) for key in request.args}
|
||||
if "sql" in params:
|
||||
params.pop("sql")
|
||||
if "_shape" in params:
|
||||
|
|
|
@ -527,7 +527,7 @@ class TableView(RowTableShared):
|
|||
|
||||
extra_args = {}
|
||||
# Handle ?_size=500
|
||||
page_size = _size or request.raw_args.get("_size")
|
||||
page_size = _size or request.args.get("_size")
|
||||
if page_size:
|
||||
if page_size == "max":
|
||||
page_size = self.ds.max_returned_rows
|
||||
|
@ -558,8 +558,8 @@ class TableView(RowTableShared):
|
|||
sql_no_limit=sql_no_limit.rstrip(), limit=page_size + 1, offset=offset
|
||||
)
|
||||
|
||||
if request.raw_args.get("_timelimit"):
|
||||
extra_args["custom_time_limit"] = int(request.raw_args["_timelimit"])
|
||||
if request.args.get("_timelimit"):
|
||||
extra_args["custom_time_limit"] = int(request.args["_timelimit"])
|
||||
|
||||
results = await db.execute(sql, params, truncate=True, **extra_args)
|
||||
|
||||
|
@ -890,7 +890,7 @@ class RowView(RowTableShared):
|
|||
"units": self.ds.table_metadata(database, table).get("units", {}),
|
||||
}
|
||||
|
||||
if "foreign_key_tables" in (request.raw_args.get("_extras") or "").split(","):
|
||||
if "foreign_key_tables" in (request.args.get("_extras") or "").split(","):
|
||||
data["foreign_key_tables"] = await self.foreign_key_tables(
|
||||
database, table, pk_values
|
||||
)
|
||||
|
|
|
@ -260,9 +260,6 @@ The request object is passed to various plugin hooks. It represents an incoming
|
|||
``.args`` - RequestParameters
|
||||
An object representing the parsed querystring parameters, see below.
|
||||
|
||||
``.raw_args`` - dictionary
|
||||
A dictionary mapping querystring keys to values. If multiple keys of the same kind are provided, e.g. ``?foo=1&foo=2``, only the first value will be present in this dictionary.
|
||||
|
||||
The object also has one awaitable method:
|
||||
|
||||
``await request.post_vars()`` - dictionary
|
||||
|
|
Ładowanie…
Reference in New Issue