webob :: response :: Response :: Class Response
[hide private]
[frames] | no frames]

Class Response

object --+
         |
        Response
Known Subclasses:

Represents a WSGI response

Nested Classes [hide private]
  RequestClass
The default request implementation
Instance Methods [hide private]
 
__call__(self, environ, start_response)
WSGI application interface
 
__init__(self, body=None, status=None, headerlist=None, app_iter=None, request=None, content_type=None, conditional_response=None, **kw)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
 
__repr__(self)
repr(x)
 
__str__(self, skip_body=False)
str(x)
 
_abs_headerlist(self, environ)
Returns a headerlist, with the Location header possibly made absolute given the request environ.
 
_add_cookie(self, cookie)
 
_app_iter__del(self)
 
_app_iter__get(self)
Returns the app_iter of the response.
 
_app_iter__set(self, value)
 
_body__del(self)
 
_body__get(self)
The body of the response, as a ``str``.
 
_body__set(self, value)
 
_body_file__del(self)
 
_body_file__get(self)
A file-like object that can be used to write to the body.
 
_cache_control__del(self)
 
_cache_control__get(self)
Get/set/modify the Cache-Control header (section `14.9 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9>`_)
 
_cache_control__set(self, value)
 
_cache_expires(self, seconds=0, **kw)
Set expiration on this request.
 
_charset__del(self)
 
_charset__get(self)
Get/set the charset (in the Content-Type)
 
_charset__set(self, charset)
 
_content_type__del(self)
 
_content_type__get(self)
Get/set the Content-Type header (or None), *without* the charset or any parameters.
 
_content_type__set(self, value)
 
_content_type_params__del(self, value)
 
_content_type_params__get(self)
A dictionary of all the parameters in the content type.
 
_content_type_params__set(self, value_dict)
 
_environ__del(self)
 
_environ__get(self)
Get/set the request environ associated with this response, if any.
 
_environ__set(self, value)
 
_headerlist__del(self)
 
_headerlist__get(self)
The list of response headers
 
_headerlist__set(self, value)
 
_headers__get(self)
The headers in a dictionary-like object
 
_headers__set(self, value)
 
_request__del(self)
 
_request__get(self)
Return the request associated with this response if any.
 
_request__set(self, value)
 
_status__get(self)
The status string
 
_status__set(self, value)
 
_status_int__get(self)
The status as an integer
 
_status_int__set(self, code)
 
_unicode_body__del(self)
 
_unicode_body__get(self)
Get/set the unicode value of the body (using the charset of the Content-Type)
 
_unicode_body__set(self, value)
 
_update_cache_control(self, prop_dict)
 
app_iter_range(self, start, stop)
Return a new app_iter built from the response app_iter, that serves up only the given ``start:stop`` range.
 
conditional_response_app(self, environ, start_response)
Like the normal __call__ interface, but checks conditional headers:
 
copy(self)
Makes a copy of the response
 
decode_content(self)
 
delete_cookie(self, key, path='/', domain=None)
Delete a cookie from the client.
 
encode_content(self, encoding='gzip')
Encode the content with the given encoding (only gzip and identity are supported).
 
md5_etag(self, body=None, set_content_md5=False)
Generate an etag for the response object using an MD5 hash of the body (the body parameter, or ``self.body`` if not given)
 
merge_cookies(self, resp)
Merge the cookies that were set on this response with the given `resp` object (which can be any WSGI application).
 
set_cookie(self, key, value='', max_age=None, path='/', domain=None, secure=None, httponly=False, version=None, comment=None, expires=None, overwrite=False)
Set (add) a cookie for the response
 
unset_cookie(self, key, strict=True)
Unset a cookie with the given name (remove it from the response).
 
write(self, text)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __sizeof__, __subclasshook__

Class Variables [hide private]
  _cache_control_obj = None
hash(x)
  _safe_methods = ('GET', 'HEAD')
  accept_ranges = <Proxy for header Accept-Ranges>
  age = <Converted <Proxy for header Age> int>
  allow = <Converted <Proxy for header Allow> list>
  cache_expires = set_via_call(<function _cache_expires at 0x102...
  content_disposition = <Proxy for header Content-Disposition>
  content_encoding = <Proxy for header Content-Encoding>
  content_language = <Converted <Proxy for header Content-Langua...
  content_length = <Converted <Proxy for header Content-Length> ...
  content_location = <Proxy for header Content-Location>
  content_md5 = <Proxy for header Content-MD5>
  content_range = <Converted <Proxy for header Content-Range> Co...
  date = <Converted <Proxy for header Date> HTTP date>
  default_charset = 'UTF-8'
  default_conditional_response = False
  default_content_type = 'text/html'
  etag = <Converted <Proxy for header ETag> Entity tag>
  expires = <Converted <Proxy for header Expires> HTTP date>
  last_modified = <Converted <Proxy for header Last-Modified> HT...
  location = <Proxy for header Location>
  pragma = <Proxy for header Pragma>
  retry_after = <Converted <Proxy for header Retry-After> HTTP d...
  server = <Proxy for header Server>
  status_code = <Deprecated attribute status_code: <property obj...
  unicode_errors = 'strict'
  vary = <Converted <Proxy for header Vary> list>
  www_authenticate = <Converted <Proxy for header WWW-Authentica...
Properties [hide private]
  app_iter
Returns the app_iter of the response.
  body
The body of the response, as a ``str``.
  body_file
A file-like object that can be used to write to the body.
  cache_control
Get/set/modify the Cache-Control header (section `14.9 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9>`_)
  charset
Get/set the charset (in the Content-Type)
  content_type
Get/set the Content-Type header (or None), *without* the charset or any parameters.
  content_type_params
A dictionary of all the parameters in the content type.
  environ
Get/set the request environ associated with this response, if any.
  headerlist
The list of response headers
  headers
The headers in a dictionary-like object
  request
Return the request associated with this response if any.
  status
The status string
  status_int
The status as an integer
  ubody
Alias for unicode_body
  unicode_body
Get/set the unicode value of the body (using the charset of the Content-Type)

Inherited from object: __class__

Method Details [hide private]

__init__(self, body=None, status=None, headerlist=None, app_iter=None, request=None, content_type=None, conditional_response=None, **kw)
(Constructor)

 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

__repr__(self)
(Representation operator)

 

repr(x)

Overrides: object.__repr__
(inherited documentation)

__str__(self, skip_body=False)
(Informal representation operator)

 

str(x)

Overrides: object.__str__
(inherited documentation)

_app_iter__get(self)

 

Returns the app_iter of the response.

If body was set, this will create an app_iter from that body (a single-item list)

_body__get(self)

 

The body of the response, as a ``str``. This will read in the entire app_iter if necessary.

_body_file__get(self)

 

A file-like object that can be used to write to the body. If you passed in a list app_iter, that app_iter will be modified by writes.

_cache_expires(self, seconds=0, **kw)

 

Set expiration on this request. This sets the response to expire in the given seconds, and any other attributes are used for cache_control (e.g., private=True, etc).

_content_type__get(self)

 

Get/set the Content-Type header (or None), *without* the charset or any parameters.

If you include parameters (or ``;`` at all) when setting the content_type, any existing parameters will be deleted; otherwise they will be preserved.

_content_type_params__get(self)

 

A dictionary of all the parameters in the content type.

(This is not a view, set to change, modifications of the dict would not be applied otherwise)

conditional_response_app(self, environ, start_response)

 

Like the normal __call__ interface, but checks conditional headers:

* If-Modified-Since (304 Not Modified; only on GET, HEAD) * If-None-Match (304 Not Modified; only on GET, HEAD) * Range (406 Partial Content; only on GET, HEAD)

delete_cookie(self, key, path='/', domain=None)

 

Delete a cookie from the client. Note that path and domain must match how the cookie was originally set.

This sets the cookie to the empty string, and max_age=0 so that it should expire immediately.

md5_etag(self, body=None, set_content_md5=False)

 

Generate an etag for the response object using an MD5 hash of the body (the body parameter, or ``self.body`` if not given)

Sets ``self.etag`` If ``set_content_md5`` is True sets ``self.content_md5`` as well

merge_cookies(self, resp)

 

Merge the cookies that were set on this response with the given `resp` object (which can be any WSGI application).

If the `resp` is a :class:`webob.Response` object, then the other object will be modified in-place.

unset_cookie(self, key, strict=True)

 

Unset a cookie with the given name (remove it from the response). If there are multiple cookies (e.g., two cookies with the same name and different paths or domains), all such cookies will be deleted.


Class Variable Details [hide private]

cache_expires

Value:
set_via_call(<function _cache_expires at 0x1028076e0>)

content_language

Value:
<Converted <Proxy for header Content-Language> list>

content_length

Value:
<Converted <Proxy for header Content-Length> int>

content_range

Value:
<Converted <Proxy for header Content-Range> ContentRange object>

last_modified

Value:
<Converted <Proxy for header Last-Modified> HTTP date>

retry_after

Value:
<Converted <Proxy for header Retry-After> HTTP date or delta seconds>

status_code

Value:
<Deprecated attribute status_code: <property object at 0x1026b8e10>>

www_authenticate

Value:
<Converted <Proxy for header WWW-Authenticate>>

Property Details [hide private]

app_iter

Returns the app_iter of the response.

If body was set, this will create an app_iter from that body (a single-item list)

Get Method:
_app_iter__get(self) - Returns the app_iter of the response.
Set Method:
_app_iter__set(self, value)
Delete Method:
_app_iter__del(self)

body

The body of the response, as a ``str``. This will read in the entire app_iter if necessary.

Get Method:
_body__get(self) - The body of the response, as a ``str``.
Set Method:
_body__set(self, value)
Delete Method:
_body__del(self)

body_file

A file-like object that can be used to write to the body. If you passed in a list app_iter, that app_iter will be modified by writes.

Get Method:
_body_file__get(self) - A file-like object that can be used to write to the body.
Delete Method:
_body_file__del(self)

cache_control

Get/set/modify the Cache-Control header (section `14.9 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9>`_)

Get Method:
_cache_control__get(self) - Get/set/modify the Cache-Control header (section `14.9 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9>`_)
Set Method:
_cache_control__set(self, value)
Delete Method:
_cache_control__del(self)

charset

Get/set the charset (in the Content-Type)

Get Method:
_charset__get(self) - Get/set the charset (in the Content-Type)
Set Method:
_charset__set(self, charset)
Delete Method:
_charset__del(self)

content_type

Get/set the Content-Type header (or None), *without* the charset or any parameters.

If you include parameters (or ``;`` at all) when setting the content_type, any existing parameters will be deleted; otherwise they will be preserved.

Get Method:
_content_type__get(self) - Get/set the Content-Type header (or None), *without* the charset or any parameters.
Set Method:
_content_type__set(self, value)
Delete Method:
_content_type__del(self)

content_type_params

A dictionary of all the parameters in the content type.

(This is not a view, set to change, modifications of the dict would not be applied otherwise)

Get Method:
_content_type_params__get(self) - A dictionary of all the parameters in the content type.
Set Method:
_content_type_params__set(self, value_dict)
Delete Method:
_content_type_params__del(self, value)

environ

Get/set the request environ associated with this response, if any.

Get Method:
_environ__get(self) - Get/set the request environ associated with this response, if any.
Set Method:
_environ__set(self, value)
Delete Method:
_environ__del(self)

headerlist

The list of response headers

Get Method:
_headerlist__get(self) - The list of response headers
Set Method:
_headerlist__set(self, value)
Delete Method:
_headerlist__del(self)

headers

The headers in a dictionary-like object

Get Method:
_headers__get(self) - The headers in a dictionary-like object
Set Method:
_headers__set(self, value)

request

Return the request associated with this response if any.

Get Method:
_request__get(self) - Return the request associated with this response if any.
Set Method:
_request__set(self, value)
Delete Method:
_request__del(self)

status

The status string

Get Method:
_status__get(self) - The status string
Set Method:
_status__set(self, value)

status_int

The status as an integer

Get Method:
_status_int__get(self) - The status as an integer
Set Method:
_status_int__set(self, code)

ubody

Alias for unicode_body

Get Method:
_unicode_body__get(self) - Get/set the unicode value of the body (using the charset of the Content-Type)
Set Method:
_unicode_body__set(self, value)
Delete Method:
_unicode_body__del(self)

unicode_body

Get/set the unicode value of the body (using the charset of the Content-Type)

Get Method:
_unicode_body__get(self) - Get/set the unicode value of the body (using the charset of the Content-Type)
Set Method:
_unicode_body__set(self, value)
Delete Method:
_unicode_body__del(self)