Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format docstrings in a consistent way. #727

Merged
merged 1 commit into from
Nov 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 15 additions & 21 deletions src/ZPublisher/BaseResponse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
# FOR A PARTICULAR PURPOSE
#
##############################################################################
'''CGI Response Output formatter
'''
"""CGI Response Output formatter"""

from six import text_type

Expand All @@ -22,8 +21,7 @@


class BaseResponse(object):
"""Base Response Class
"""
"""Base Response Class"""
body = b''
debug_mode = None
_auth = None
Expand Down Expand Up @@ -54,7 +52,7 @@ def setHeader(self, name, value):
__setitem__ = setHeader

def outputBody(self):
"""Output the response body"""
"""Output the response body."""
self.stdout.write(bytes(self))

def setBody(self, body):
Expand All @@ -63,18 +61,17 @@ def setBody(self, body):
self.body = body

def getStatus(self):
'Returns the current HTTP status code as an integer. '
"""Returns the current HTTP status code as an integer."""
return self.status

def setCookie(self, name, value, **kw):
'''
Set an HTTP cookie on the browser
"""Set an HTTP cookie on the browser.

The response will include an HTTP header that sets a cookie on
cookie-enabled browsers with a key "name" and value
"value". This overwrites any previously set value for the
cookie in the Response object.
'''
"""
cookies = self.cookies
if name in cookies:
cookie = cookies[name]
Expand All @@ -88,21 +85,20 @@ def appendBody(self, body):
self.setBody(self.getBody() + body)

def getHeader(self, name):
'''
Get a header value
"""Get a header value.

Returns the value associated with a HTTP return header, or
"None" if no such header has been set in the response
yet.
'''
"""
return self.headers.get(name, None)

def __getitem__(self, name):
'Get the value of an output header'
"""Get the value of an output header."""
return self.headers[name]

def getBody(self):
'Returns bytes representing the currently set body. '
"""Returns bytes representing the currently set body."""
return self.body

def __bytes__(self):
Expand All @@ -115,8 +111,7 @@ def flush(self):
pass

def write(self, data):
"""
Return data as a stream
"""Return data as a stream.

HTML data may be returned using a stream-oriented interface.
This allows the browser to display partial results while
Expand All @@ -142,20 +137,19 @@ def exception(self, fatal=0, info=None):
"""

def notFoundError(self, v=''):
"""Generate an error indicating that an object was not found.
"""
"""Generate an error indicating that an object was not found."""
raise NotFound(v)

def debugError(self, v=''):
"""Raise an error with debugging info and in debugging mode"""
"""Raise an error with debugging info and in debugging mode."""
raise NotFound("Debugging notice: %s" % v)

def badRequestError(self, v=''):
"""Raise an error indicating something wrong with the request"""
"""Raise an error indicating something wrong with the request."""
raise BadRequest(v)

def forbiddenError(self, v=''):
"""Raise an error indicating that the request cannot be done"""
"""Raise an error indicating that the request cannot be done."""
raise Forbidden(v)

def unauthorized(self):
Expand Down