Changeset 2675
- Timestamp:
- 04/11/06 08:43:29 (3 years ago)
- Files:
-
- django/trunk/django/utils/httpwrappers.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/utils/httpwrappers.py
r2642 r2675 152 152 mimetype = "%s; charset=%s" % (settings.DEFAULT_CONTENT_TYPE, settings.DEFAULT_CHARSET) 153 153 if hasattr(content, '__iter__'): 154 self. iterator = content154 self._iterator = content 155 155 self._is_string = False 156 156 else: 157 self. iterator = [content]157 self._iterator = [content] 158 158 self._is_string = True 159 159 self.headers = {'Content-Type': mimetype} … … 201 201 202 202 def _get_content(self): 203 content = ''.join(self. iterator)203 content = ''.join(self._iterator) 204 204 if isinstance(content, unicode): 205 205 content = content.encode(self._charset) … … 207 207 208 208 def _set_content(self, value): 209 self. iterator = [value]209 self._iterator = [value] 210 210 self._is_string = True 211 211 212 212 content = property(_get_content, _set_content) 213 214 def _get_iterator(self): 215 "Output iterator. Converts data into client charset if necessary." 216 for chunk in self._iterator: 217 if isinstance(chunk, unicode): 218 chunk = chunk.encode(self._charset) 219 yield chunk 220 221 iterator = property(_get_iterator) 213 222 214 223 # The remaining methods partially implement the file-like object interface. … … 217 226 if not self._is_string: 218 227 raise Exception, "This %s instance is not writable" % self.__class__ 219 self. iterator.append(content)228 self._iterator.append(content) 220 229 221 230 def flush(self): … … 225 234 if not self._is_string: 226 235 raise Exception, "This %s instance cannot tell its position" % self.__class__ 227 return sum([len(chunk) for chunk in self. iterator])236 return sum([len(chunk) for chunk in self._iterator]) 228 237 229 238 class HttpResponseRedirect(HttpResponse):
