测试gitnore
This commit is contained in:
@@ -8,18 +8,10 @@ class ContentNotRenderedError(Exception):
|
||||
|
||||
|
||||
class SimpleTemplateResponse(HttpResponse):
|
||||
rendering_attrs = ["template_name", "context_data", "_post_render_callbacks"]
|
||||
rendering_attrs = ['template_name', 'context_data', '_post_render_callbacks']
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
template,
|
||||
context=None,
|
||||
content_type=None,
|
||||
status=None,
|
||||
charset=None,
|
||||
using=None,
|
||||
headers=None,
|
||||
):
|
||||
def __init__(self, template, context=None, content_type=None, status=None,
|
||||
charset=None, using=None, headers=None):
|
||||
# It would seem obvious to call these next two members 'template' and
|
||||
# 'context', but those names are reserved as part of the test Client
|
||||
# API. To avoid the name collision, we use different names.
|
||||
@@ -41,7 +33,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
# content argument doesn't make sense here because it will be replaced
|
||||
# with rendered template so we always pass empty string in order to
|
||||
# prevent errors and provide shorter signature.
|
||||
super().__init__("", content_type, status, charset=charset, headers=headers)
|
||||
super().__init__('', content_type, status, charset=charset, headers=headers)
|
||||
|
||||
# _is_rendered tracks whether the template and context has been baked
|
||||
# into a final response.
|
||||
@@ -57,9 +49,8 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
"""
|
||||
obj_dict = self.__dict__.copy()
|
||||
if not self._is_rendered:
|
||||
raise ContentNotRenderedError(
|
||||
"The response content must be rendered before it can be pickled."
|
||||
)
|
||||
raise ContentNotRenderedError('The response content must be '
|
||||
'rendered before it can be pickled.')
|
||||
for attr in self.rendering_attrs:
|
||||
if attr in obj_dict:
|
||||
del obj_dict[attr]
|
||||
@@ -125,7 +116,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
def __iter__(self):
|
||||
if not self._is_rendered:
|
||||
raise ContentNotRenderedError(
|
||||
"The response content must be rendered before it can be iterated over."
|
||||
'The response content must be rendered before it can be iterated over.'
|
||||
)
|
||||
return super().__iter__()
|
||||
|
||||
@@ -133,7 +124,7 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
def content(self):
|
||||
if not self._is_rendered:
|
||||
raise ContentNotRenderedError(
|
||||
"The response content must be rendered before it can be accessed."
|
||||
'The response content must be rendered before it can be accessed.'
|
||||
)
|
||||
return super().content
|
||||
|
||||
@@ -145,20 +136,9 @@ class SimpleTemplateResponse(HttpResponse):
|
||||
|
||||
|
||||
class TemplateResponse(SimpleTemplateResponse):
|
||||
rendering_attrs = SimpleTemplateResponse.rendering_attrs + ["_request"]
|
||||
rendering_attrs = SimpleTemplateResponse.rendering_attrs + ['_request']
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
request,
|
||||
template,
|
||||
context=None,
|
||||
content_type=None,
|
||||
status=None,
|
||||
charset=None,
|
||||
using=None,
|
||||
headers=None,
|
||||
):
|
||||
super().__init__(
|
||||
template, context, content_type, status, charset, using, headers=headers
|
||||
)
|
||||
def __init__(self, request, template, context=None, content_type=None,
|
||||
status=None, charset=None, using=None, headers=None):
|
||||
super().__init__(template, context, content_type, status, charset, using, headers=headers)
|
||||
self._request = request
|
||||
|
||||
Reference in New Issue
Block a user