Package wtf :: Package app :: Module http_response :: Class HTTPResponse
[hide private]
[frames] | no frames]

Class HTTPResponse

source code

              object --+        
                       |        
exceptions.BaseException --+    
                           |    
       exceptions.SystemExit --+
                               |
                              HTTPResponse
Known Subclasses:

Base HTTP error response exception class

The exception is derived from SystemExit on purpose - that way it should wind up the whole try-except stack (if well-written: nobody should swallow SystemExit) until explicitly caught.

Instance Methods [hide private]
 
__init__(self, request, message=None, content_type='text/html; charset=us-ascii', replace=True, **param)
Initialization
source code
tuple
init(self)
Custom initializer and easy check for required parameters
source code
 
headers(self, collection)
Modify response headers
source code
str
body(self)
Compute the response body
source code

Inherited from exceptions.SystemExit: __new__

Inherited from exceptions.BaseException: __delattr__, __getattribute__, __getitem__, __getslice__, __reduce__, __repr__, __setattr__, __setstate__, __str__, __unicode__

Inherited from object: __format__, __hash__, __reduce_ex__, __sizeof__, __subclasshook__

Class Variables [hide private]
str _FRAME = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\n...
Frame around the actual message
str reason = None
HTTP response reason phrase
int status = None
HTTP response status
Instance Variables [hide private]
str _content_type
Content-Type
dict _escaped
Already escaped parameters
bool _replace
Replace parameters in message?
str message = None
Message template
dict param
Additional parameters for response template fill-in
Properties [hide private]

Inherited from exceptions.SystemExit: code

Inherited from exceptions.BaseException: args

Inherited from object: __class__

Method Details [hide private]

__init__(self, request, message=None, content_type='text/html; charset=us-ascii', replace=True, **param)
(Constructor)

source code 
Initialization
Parameters:
  • request (wtf.app.request.Request) - Request object
  • message (str) - message template
  • content_type (str) - Response content type
  • replace (bool) - Replace parameters in message?
  • param (dict) - Additional parameters for response template fill-in
Overrides: object.__init__

init(self)

source code 
Custom initializer and easy check for required parameters
Returns: tuple
tuple of unescaped and escaped parameters ((dict, dict))

body(self)

source code 
Compute the response body
Returns: str
The response body

Class Variable Details [hide private]

_FRAME

Frame around the actual message
Type:
str
Value:
'''<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>%%(status)s %%(reason)s</title>
</head><body>
<h1>%%(reason)s</h1>
%s
</body></html>'''