Devels,
  I've noticed in the docs that HttpResponse objects, if initialised
with an iterator, cannot be used as file-like objects. This could be
fixed quite easily. At the moment, if the response was not initialised
with a string, then an error is raised when you try to write to it.
Instead, all that needs to be done is this (modified from
HttpResponse.write() definition):

    def write(self, content):
        if not self._is_string:
            self._container = itertools.chain(self._container,
[content])
        else:
            self._container.append(content)

In addition, HttpResponse.tell() doesn't allow you to get the position
if the HttpResponse uses an iterator. This could be worked around like
this:

       def tell(self):
            if not self._is_string:
                self._container, temp_iter =
itertools.tee(self._container)
            else:
                temp_iter = self._container
            return sum(len(chunk) for chunk in temp_iter)

Regards,
Zack
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to