diff options
| author | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-22 07:15:04 +0000 |
|---|---|---|
| committer | Malcolm Tredinnick <malcolm.tredinnick@gmail.com> | 2007-06-22 07:15:04 +0000 |
| commit | 880e3cfaa6040bb745ecfdbd91be0234cdb87278 (patch) | |
| tree | de1fb452e66a3ce1946e977937696219a9878f8f /django/http | |
| parent | dbebf54d6c189a4ccd157d1ee3640b2292d6225e (diff) | |
Backed out the changes in [5482] for a bit whilst some more investigation into
side-effects is done. Refs #4565.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5511 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/__init__.py | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/django/http/__init__.py b/django/http/__init__.py index a8c8afe433..ca3b5eab24 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -222,12 +222,6 @@ class HttpResponse(object): content = ''.join(self._container) if isinstance(content, unicode): content = content.encode(self._charset) - - # If self._container was an iterator, we have just exhausted it, so we - # need to save the results for anything else that needs access - if not self._is_string: - self._container = [content] - self._is_string = True return content def _set_content(self, value): @@ -237,10 +231,14 @@ class HttpResponse(object): content = property(_get_content, _set_content) def __iter__(self): - for chunk in self._container: - if isinstance(chunk, unicode): - chunk = chunk.encode(self._charset) - yield chunk + self._iterator = self._container.__iter__() + return self + + def next(self): + chunk = self._iterator.next() + if isinstance(chunk, unicode): + chunk = chunk.encode(self._charset) + return chunk def close(self): if hasattr(self._container, 'close'): |
