@@ -52,34 +52,37 @@ def __getattr__(self, attr):
5252 except TypeError :
5353 raise AttributeError (attr )
5454
55- class HttpResponseWrapper (HttpResponse ):
56- """
57- Wrap HttpResponse and make sure that the internal
58- _is_string/_base_content_is_iter flag is updated when the
59- _set_content method (via the content property) is called
60- """
61- def _set_content (self , content ):
55+ if django .VERSION < (1 , 5 ):
56+ class HttpResponseWrapper (HttpResponse ):
6257 """
63- Set the _container and _is_string /
64- _base_content_is_iter properties based on the type of
65- the value parameter. This logic is in the construtor
66- for HttpResponse, but doesn't get repeated when
67- setting HttpResponse.content although this bug report
68- (feature request) suggests that it should:
69- http://code.djangoproject.com/ticket/9403
58+ Wrap HttpResponse and make sure that the internal
59+ _is_string/_base_content_is_iter flag is updated when the
60+ _set_content method (via the content property) is called
7061 """
71- is_string = False
72- if not isinstance (content , basestring ) and hasattr (content , '__iter__' ):
73- self ._container = content
74- else :
75- self ._container = [content ]
76- is_string = True
77- if django .VERSION >= (1 , 4 ):
78- self ._base_content_is_iter = not is_string
79- else :
80- self ._is_string = is_string
81-
82- content = property (HttpResponse ._get_content , _set_content )
62+ def _set_content (self , content ):
63+ """
64+ Set the _container and _is_string /
65+ _base_content_is_iter properties based on the type of
66+ the value parameter. This logic is in the construtor
67+ for HttpResponse, but doesn't get repeated when
68+ setting HttpResponse.content although this bug report
69+ (feature request) suggests that it should:
70+ http://code.djangoproject.com/ticket/9403
71+ """
72+ is_string = False
73+ if not isinstance (content , basestring ) and hasattr (content , '__iter__' ):
74+ self ._container = content
75+ else :
76+ self ._container = [content ]
77+ is_string = True
78+ if django .VERSION >= (1 , 4 ):
79+ self ._base_content_is_iter = not is_string
80+ else :
81+ self ._is_string = is_string
82+
83+ content = property (HttpResponse ._get_content , _set_content )
84+ else :
85+ HttpResponseWrapper = HttpResponse
8386
8487 return HttpResponseWrapper (r , content_type = 'text/plain' , status = c )
8588
0 commit comments