-
Notifications
You must be signed in to change notification settings - Fork 83
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
DEP 0015 Content Type Parsing #88
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Brilliant, thanks for getting this started as a DEP 🥳
- Introduce content type parsing and only add the new ``data`` attribute. | ||
|
||
The new names for unchanged attributes is proposed as it's considered this a worthwhile improvement in its own right and introduces consistent naming across ``HttpRequest`` attributes. That is, without renaming the change only the new ``data`` attribute would be an outlier. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can also add a note that django-upgrade could automate refactoring code to use the new lowercased attributes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Initial work showing this is possible: smithdc1/django-upgrade@c043761
draft/0015-content-types.rst
Outdated
|
||
Parsed data from an ``HttpRequest`` is accessed via its ``POST`` attribute. It would be a breaking change if Django were to start parsing content types where currently a string is returned. To avoid introducing a breaking change it is proposed that a new ``data`` attribute is added for the new behaviour. | ||
|
||
While introducing a new name for ``POST`` it is proposed that the names for the other attributes are modernized with an equivalent behaviour. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally proposed request.form_data
as the new lowercase name for request.POST
back in Ticket 32259, I’d like that we still keep that. We can’t find-and-replace request.POST
with request.data
without adding new functionality unsafely.
Also, let’s list the renames right here in the abstract, so they’re easy for future readers to find:
While introducing a new name for ``POST`` it is proposed that the names for the other attributes are modernized with an equivalent behaviour. | |
While introducing a new name for ``POST`` it is proposed that the names for the other attributes are modernized with an equivalent behaviour: | |
* ``GET`` -> ``query_params`` | |
* ``POST`` -> ``form_data`` | |
* ``COOKIES`` -> ``cookies` | |
* ``META`` -> ``meta`` | |
* ``FILES`` -> ``files`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think form_data
is confusing.
In the first place, GET forms are a thing. But once you're parsing other content types from the body, there's no form even in play at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
post_form_data
? I would just like another lowercase name for the existing attribute so it’s not left uppercase-only, requiring users to adopt data
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you mean as well as then adding the data
attribute? I'd misunderstood.
OK, yes, something like that makes sense.
Let's discuss in Vigo, where we can likely bikeshed it to death over less than a single coffee ☕️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having spoken with @adamchainz at DjangoCon, I agree with him. Adding form_data
as an alias to POST
, maintaining the existing behaviour is a good idea. 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case could this DEP become just about renaming?
That would allow django/django#17546 to make progress without this?
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think?
My honest take is that we need both. I don't think renaming things without adding anything is great, and just sticking the data
object on without updating the request seems an error.
But, logically, yes, maybe. One strategy would be to plough on and see where we get.
Thanks for picking this up @smithdc1! 🎁 Good timing. Let's chat in Vigo. |
Co-authored-by: Adam Johnson <[email protected]>
Co-authored-by: Adam Johnson <[email protected]>
Co-authored-by: Adam Johnson <[email protected]>
Hi All, Not to sure where exactly to leave/put this feedback but wanted to at least mention some concerns: First of all I think keeping Regarding content-negotiation, I have some of concerns:
Anyway that's just a quick rant / two cents about content-negotiation, doesn't need to hold things up, but I thought I'd at least mention these issues for my own sake so they're not swirling around in my head forever. Thanks, |
Thank you for your thoughts -- A couple of responses from me. I'm happy to add these to the DEP if that would be helpful.
I think ensuring compliance with the
I agree that the behavior for |
Hi @carltongibson 👋
I've made a start on writing up a DEP following the discussion on the forum. This is based upon previous discussions both on the mailing list, the forum and the linked PRs.
There's a couple of "TODO"s which need a bit more thought. But thought worth sharing where I have got to.
I hope that I have presented a fair and unbiased proposal of where we are and the concerns raised.