Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rename `serialize` to `write`

This is doing more than simply serializing the response content and
it updates the response in-place, so `write` is more appropriate
  • Loading branch information...
commit fda2d59afe3289596499abc1972baa09bd6ccaf7 1 parent dc7d0ee
@bruth authored
Showing with 9 additions and 8 deletions.
  1. +9 −8 restlib2/resources.py
View
17 restlib2/resources.py
@@ -504,7 +504,7 @@ def content_language_supported(self, request, response, *args, **kwargs):
return True
# Utility methods
- def serialize(self, request, response, content, accept_type=None):
+ def write(self, request, response, content, accept_type=None):
if content is None:
response.status_code = codes.no_content
elif isinstance(content, basestring) or isinstance(content, file):
@@ -526,20 +526,21 @@ def get_cache_timeout(self, request, response):
return self.cache_max_age
def response_cache_control(self, request, response):
- cc = {}
+ attrs = {}
timeout = self.get_cache_timeout(request, response)
+
# If explicit 0, do no apply max-age or expires
if isinstance(timeout, datetime):
response['Expires'] = http_date(timegm(timeout.utctimetuple()))
- elif isinstance(self.cache_max_age, int):
- cc['max_age'] = self.cache_max_age
+ elif isinstance(timeout, int):
+ attrs['max_age'] = timeout
if self.private_cache:
- cc['private'] = True
+ attrs['private'] = True
else:
- cc['public'] = True
+ attrs['public'] = True
- patch_cache_control(response, **cc)
+ patch_cache_control(response, **attrs)
response['Pragma'] = response['Cache-Control']
# Process methods
@@ -706,7 +707,7 @@ def process_response(self, request, response):
response = HttpResponse()
if request.method != methods.HEAD:
- self.serialize(request, response, content)
+ self.write(request, response, content)
if request.method == methods.HEAD:
response.content = ''
Please sign in to comment.
Something went wrong with that request. Please try again.