--
Ticket URL: <https://code.djangoproject.com/ticket/18523>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* stage: Unreviewed => Accepted
Comment:
Good idea.
Do Python's docs provide a list of the methods that a "stream object" must
support? While we're there, we should also check that HttpRequest objects
support all the methods that make sense.
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:1>
Comment (by claudep):
I think http://docs.python.org/library/io.html?highlight=stream#io.IOBase
lists basic API for streams.
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:2>
Comment (by unaizalakain):
I would add the following attributes and methods:
- `HttpResponseBase.closed`: set to `False` in `__init__`, set to `True`
in `close()`
- `HttpResponseBase.writable()`: returns `False` because `write(content)`
raises an exception (should be changed to `IOError` BTW)
- `HttpResponseBase.writelines(lines)`: raises `IOError`
- `HttpResponseBase.tell()`: change it to raise `IOError`
- `HttpResponse.getvalue()`: returns `self.content`
- `HttpResponse.writelines(lines)`: writes each line with
`self.write(line)`
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:3>
* owner: nobody => Osmose
* status: new => assigned
* has_patch: 0 => 1
Comment:
I submitted a PR with the changes mentioned in comment:3 here:
https://github.com/django/django/pull/2545
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:4>
* needs_better_patch: 0 => 1
Comment:
There are some comments for improvement on the PR. Please uncheck "Patch
needs improvement" when you update it, thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:5>
Comment (by Osmose):
Will do, just having trouble finding a good time to work on this lately.
:D
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:6>
* needs_better_patch: 1 => 0
Comment:
Updated branch with changes in response to feedback. :D
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:7>
* needs_better_patch: 0 => 1
Comment:
There are some problems with the tests on Python 3.
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:8>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:9>
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:10>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"ebc8e79cf3bdd42a99e91d6e679248d07097d3db"]:
{{{
#!CommitTicketReference repository=""
revision="ebc8e79cf3bdd42a99e91d6e679248d07097d3db"
Fixed #18523 -- Added stream-like API to HttpResponse.
Added getvalue() to HttpResponse to return the content of the response,
along with a few other methods to partially match io.IOBase.
Thanks Claude Paroz for the suggestion and Nick Sanford for review.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18523#comment:11>