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.
 
_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)
 
_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', lazy=False)
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=False, httponly=False, 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 Methods [hide private]
 
from_file(cls, fp)
Reads a response from a file-like object (it must implement ``.read(size)`` and ``.readline()``).
Class Variables [hide private]
  _cache_control_obj = None
hash(x)
  _safe_methods = ('GET', 'HEAD')
  default_charset = 'UTF-8'
  default_conditional_response = False
  default_content_type = 'text/html'
  status_code = <Deprecated attribute status_code: <property obj...
  unicode_errors = 'strict'
Properties [hide private]
  accept_ranges
Gets and sets and deletes the Accept-Ranges header.
  age
Gets and sets and deletes the Age header.
  allow
Gets and sets and deletes the Allow header.
  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>`_)
  cache_expires
  charset
Get/set the charset (in the Content-Type)
  content_disposition
Gets and sets and deletes the Content-Disposition header.
  content_encoding
Gets and sets and deletes the Content-Encoding header.
  content_language
Gets and sets and deletes the Content-Language header.
  content_length
Gets and sets and deletes the Content-Length header.
  content_location
Gets and sets and deletes the Content-Location header.
  content_md5
Gets and sets and deletes the Content-MD5 header.
  content_range
Gets and sets and deletes the Content-Range header.
  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.
  date
Gets and sets and deletes the Date header.
  environ
Get/set the request environ associated with this response, if any.
  etag
Gets and sets and deletes the ETag header.
  expires
Gets and sets and deletes the Expires header.
  headerlist
The list of response headers
  headers
The headers in a dictionary-like object
  last_modified
Gets and sets and deletes the Last-Modified header.
  location
Gets and sets and deletes the Location header.
  pragma
Gets and sets and deletes the Pragma header.
  request
Return the request associated with this response if any.
  retry_after
Gets and sets and deletes the Retry-After header.
  server
Gets and sets and deletes the Server header.
  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)
  vary
Gets and sets and deletes the Vary header.
  www_authenticate
Gets and sets and deletes the WWW-Authenticate header.

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.

from_file(cls, fp)
Class Method

 

Reads a response from a file-like object (it must implement ``.read(size)`` and ``.readline()``).

It will read up to the end of the response, not the end of the file.

This reads the response as represented by ``str(resp)``; it may not read every valid HTTP response properly. Responses must have a ``Content-Length``

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.


Class Variable Details [hide private]

status_code

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

Property Details [hide private]

accept_ranges

Gets and sets and deletes the Accept-Ranges header. For more information on Accept-Ranges see `section 14.5 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.5>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

age

Gets and sets and deletes the Age header. For more information on Age see `section 14.6 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.6>`_. Converts it as a int.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

allow

Gets and sets and deletes the Allow header. For more information on Allow see `section 14.7 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.7>`_. Converts it as a list.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

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)

cache_expires

Get Method:
unreachable(self)
Set Method:
_cache_expires(self, seconds=0, **kw) - Set expiration on this request.

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_disposition

Gets and sets and deletes the Content-Disposition header. For more information on Content-Disposition see `section 19.5.1 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec19.html#sec19.5.1>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

content_encoding

Gets and sets and deletes the Content-Encoding header. For more information on Content-Encoding see `section 14.11 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

content_language

Gets and sets and deletes the Content-Language header. For more information on Content-Language see `section 14.12 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.12>`_. Converts it as a list.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

content_length

Gets and sets and deletes the Content-Length header. For more information on Content-Length see `section 14.17 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.17>`_. Converts it as a int.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

content_location

Gets and sets and deletes the Content-Location header. For more information on Content-Location see `section 14.14 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

content_md5

Gets and sets and deletes the Content-MD5 header. For more information on Content-MD5 see `section 14.14 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.14>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

content_range

Gets and sets and deletes the Content-Range header. For more information on Content-Range see `section 14.16 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.16>`_. Converts it as a ContentRange object.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

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)

date

Gets and sets and deletes the Date header. For more information on Date see `section 14.18 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.18>`_. Converts it as a HTTP date.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

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)

etag

Gets and sets and deletes the ETag header. For more information on ETag see `section 14.19 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19>`_. Converts it as a Entity tag.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

expires

Gets and sets and deletes the Expires header. For more information on Expires see `section 14.21 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21>`_. Converts it as a HTTP date.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

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)

last_modified

Gets and sets and deletes the Last-Modified header. For more information on Last-Modified see `section 14.29 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29>`_. Converts it as a HTTP date.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

location

Gets and sets and deletes the Location header. For more information on Location see `section 14.30 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.30>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

pragma

Gets and sets and deletes the Pragma header. For more information on Pragma see `section 14.32 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.32>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

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)

retry_after

Gets and sets and deletes the Retry-After header. For more information on Retry-After see `section 14.37 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.37>`_. Converts it as a HTTP date or delta seconds.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

server

Gets and sets and deletes the Server header. For more information on Server see `section 14.38 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.38>`_.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, value)
Delete Method:
unreachable.fdel(r)

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)

vary

Gets and sets and deletes the Vary header. For more information on Vary see `section 14.44 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.44>`_. Converts it as a list.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)

www_authenticate

Gets and sets and deletes the WWW-Authenticate header. For more information on WWW-Authenticate see `section 14.47 <http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.47>`_. Converts it as a <function parse_auth at 0x102d47b90> and <function serialize_auth at 0x102d47c08>.

Get Method:
unreachable.fget(r)
Set Method:
unreachable.fset(r, val)
Delete Method:
unreachable.fdel(r)