Skip to content
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

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

Open
simonw opened this issue Sep 9, 2024 · 1 comment
Open

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

simonw opened this issue Sep 9, 2024 · 1 comment

Comments

@simonw
Copy link
Owner

simonw commented Sep 9, 2024

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:

@simonw
Copy link
Owner Author

simonw commented Sep 9, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant