simonw/datasette

`request.post_vars()` cannot handle multiple values for a key

simonw opened this issue · 1 comments

async def post_vars(self):
body = await self.post_body()
return dict(parse_qsl(body.decode("utf-8"), keep_blank_values=True))

Datasette GET requests often use ?_facet=category&_facet=size - but right now there's no neat way to handle that with POST data, since this code reduces any multiple values to just one.

This came up while working with <select multiple> (enhanced using Choices.js) in:

Fixing this may be as simple as returning a MultiParams instead:

@property
def args(self):
return MultiParams(parse_qs(qs=self.query_string, keep_blank_values=True))

That should behave like a regular dictionary so it's possible it won't break existing plugins?