Package Pyblosxom :: Module pyblosxom :: Class Response
[hide private]
[frames] | no frames]

Class Response

source code

object --+
         |
        Response

Response class to handle all output related tasks in one place.

This class is basically a wrapper arround a StringIO instance. It also provides methods for managing http headers.

Instance Methods [hide private]
 
__init__(self, request)
Sets the Request object that leaded to this response.
source code
 
__iter__(self)
Can't copy the __iter__ method over from the StringIO instance cause iter looks for the method in the class instead of the instance.
source code
 
setStatus(self, status)
Sets the status code for this response.
source code
 
getStatus(self)
Returns the status code and message of this response.
source code
 
addHeader(self, *args)
Populates the HTTP header with lines of text.
source code
dict
getHeaders(self)
Returns the headers of this response.
source code
 
sendHeaders(self, out)
Send HTTP Headers to the given output stream.
source code
 
sendBody(self, out)
Send the response body to the given output stream.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, request)
(Constructor)

source code 
Sets the Request object that leaded to this response. Creates a StringIO that is used as a output buffer.
Parameters:
  • request (Request) - request object.
Overrides: object.__init__

__iter__(self)

source code 

Can't copy the __iter__ method over from the StringIO instance cause iter looks for the method in the class instead of the instance.

See http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/252151

setStatus(self, status)

source code 
Sets the status code for this response.
Parameters:
  • status (str) - A status code and message like '200 OK'.

getStatus(self)

source code 
Returns the status code and message of this response.
Returns:
str

addHeader(self, *args)

source code 
Populates the HTTP header with lines of text. Sets the status code on this response object if the given argument list containes a 'Status' header.
Parameters:
  • args (argument lists) - Paired list of headers
Raises:
  • ValueError - This happens when the parameters are not correct

getHeaders(self)

source code 
Returns the headers of this response.
Returns: dict
the HTTP response headers

sendHeaders(self, out)

source code 
Send HTTP Headers to the given output stream.
Parameters:
  • out (file) - File like object

sendBody(self, out)

source code 
Send the response body to the given output stream.
Parameters:
  • out (file) - File like object