-
-
Notifications
You must be signed in to change notification settings - Fork 947
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
Unify behavior between asgi and wsgi #1679
Comments
Hi 👋, Thanks for using Falcon. The large amount of time and effort needed to Please consider helping us secure the future of the Falcon framework with a Thank you for your support! |
@vytas7 on gitter pointed out that there are also other differences between wsgi and asgi. Like the This is mainly because an async property is odd, and may trick people that are not used to this. To try and have an api as uniform as possible between asgi and wsgi, maybe an heuristic could be:
|
Anything doing I/O is probably better off as a method. However, even if we adopt this thinking, we'll have to provide WSGI property compatibility aliases for a long time. Serious interface stability is among the main selling points of Falcon, after all. |
If they are just getters, the alias would be just Maybe the path could be. Alias in v3 (maybe deprecated just in the comments), deprecate in v4, remove v5? For asgi and multipart, since they are new, the alias would not be there? |
I'd say just alias in v3 but do not deprecated until v4.
For ASGI we are trying to make it as similar as possible to WSGI (minus stuff that is deprecated in WSGI for v3), so I think it would still be a good idea to, for example, add a req.media property alias. |
I can try working on it. I'll start by unifying the request and response classes |
@CaselIT I think you should coordinate this with @kgriffs as we've just merged the PR for ASGI reintroducing the async One thing that is IMHO clearly worth unifying, is |
Yes, that was the plan for now I think. Have both, at least in the wsgi version. |
Let's start with a PR and breaking change notes in docstrings and towncrier news for updating WSGI per Can you enumerate/add a checklist for any other changes you were considering? |
Here is what I've found:
It's probably not exhaustive |
* refactor(requrest): avoid duplication of prefix, add get_media to wsgi method * refactor(response): add render_body to wsgi response. Also unify data and media behavior between asgi and wsgi * test(response): additional tests to render_body * docs: add newsfragment * docs: fix typo in changelog * doc(falcon.Response): Expand news fragment for render_body() * doc(Response): Update docstrings for render_body() * doc(Response): Update docstrings for media and get_body() * doc(Request): Add news fragment re get_media() Fixes #1679 Partially-Implements #1358 Co-authored-by: Vytautas Liuolia <vytautas.liuolia@gmail.com> Co-authored-by: Kurt Griffiths <mail@kgriffs.com>
Currently the implementation of the response class for the wsgi and the asgi differ when handling the
data
property. Namely the asgi version does not override data with the media value, while the wsgi version overrides the data with the media serialization data.In the code on master there are currently these todos
falcon/falcon/response.py
Lines 192 to 195 in c3e9187
falcon/falcon/response.py
Lines 192 to 195 in c3e9187
Should the wsgi response class behave like the asgi, and use the method
render_body
to get the body in the response?The text was updated successfully, but these errors were encountered: