WebOb
-
class webob.Request(environ=None, environ_getter=None, charset=(No Default), unicode_errors=(No Default), decode_param_names=(No Default), **kw)
-
GET
- Like .str_GET, but may decode values and keys
-
POST
- Like .str_POST, but may decode values and keys
-
ResponseClass
- alias of Response
-
accept
- Gets and sets and deletes the ‘HTTP_ACCEPT’ key from the environment. For more information on Accept see section 14.1. Converts it as a MIME Accept.
-
accept_charset
- Gets and sets and deletes the ‘HTTP_ACCEPT_CHARSET’ key from the environment. For more information on Accept-Charset see section 14.2. Converts it as a accept header.
-
accept_encoding
- Gets and sets and deletes the ‘HTTP_ACCEPT_ENCODING’ key from the environment. For more information on Accept-Encoding see section 14.3. Converts it as a accept header.
-
accept_language
- Gets and sets and deletes the ‘HTTP_ACCEPT_LANGUAGE’ key from the environment. For more information on Accept-Language see section 14.4. Converts it as a accept header.
-
application_url
- The URL including SCRIPT_NAME (no PATH_INFO or query string)
-
classmethod blank(path, environ=None, base_url=None, headers=None, **kw)
Create a blank request environ (and Request wrapper) with the
given path (path should be urlencoded), and any keys from
environ.
The path will become path_info, with any query string split
off and used.
All necessary keys will be added to the environ, but the
values you pass in will take precedence. If you pass in
base_url then wsgi.url_scheme, HTTP_HOST, and SCRIPT_NAME will
be filled in from that value.
Any extra keyword will be passed to __init__ (e.g.,
decode_param_names).
-
body
- Return the content of the request body.
-
body_file
Access the body of the request (wsgi.input) as a file-like
object.
If you set this value, CONTENT_LENGTH will also be updated
(either set to -1, 0 if you delete the attribute, or if you
set the attribute to a string then the length of the string).
-
cache_control
- Get/set/modify the Cache-Control header (section 14.9)
-
call_application(application, catch_exc_info=False)
Call the given WSGI application, returning (status_string,
headerlist, app_iter)
Be sure to call app_iter.close() if it’s there.
If catch_exc_info is true, then returns (status_string,
headerlist, app_iter, exc_info), where the fourth item may
be None, but won’t be if there was an exception. If you don’t
do this and there was an exception, the exception will be
raised directly.
-
content_length
- Gets and sets and deletes the ‘CONTENT_LENGTH’ key from the environment. For more information on CONTENT_LENGTH see section 14.13. Converts it as a int.
-
content_type
- Gets and sets and deletes the ‘CONTENT_TYPE’ key from the environment. For more information on CONTENT_TYPE see section 14.17.
-
cookies
- Like .str_cookies, but may decode values and keys
-
copy()
Copy the request and environment object.
This only does a shallow copy, except of wsgi.input
-
copy_body()
Copies the body, in cases where it might be shared with
another request object and that is not desired.
This copies the body in-place, either into a StringIO object
or a temporary file.
-
copy_get()
- Copies the request and environment object, but turning this request
into a GET along the way. If this was a POST request (or any other verb)
then it becomes GET, and the request body is thrown away.
-
date
- Gets and sets and deletes the ‘HTTP_DATE’ key from the environment. For more information on Date see section 14.8. Converts it as a HTTP date.
-
get_response(application, catch_exc_info=False)
Like .call_application(application), except returns a
response object with .status, .headers, and .body
attributes.
This will use self.ResponseClass to figure out the class
of the response object to return.
- All the request headers as a case-insensitive dictionary-like
object.
-
host
- Host name provided in HTTP_HOST, with fall-back to SERVER_NAME
-
host_url
- The URL through the host (no path)
-
if_match
- Gets and sets and deletes the ‘HTTP_IF_MATCH’ key from the environment. For more information on If-Match see section 14.24. Converts it as a ETag.
-
if_modified_since
- Gets and sets and deletes the ‘HTTP_IF_MODIFIED_SINCE’ key from the environment. For more information on If-Modified-Since see section 14.25. Converts it as a HTTP date.
-
if_none_match
- Gets and sets and deletes the ‘HTTP_IF_NONE_MATCH’ key from the environment. For more information on If-None-Match see section 14.26. Converts it as a ETag.
-
if_range
- Gets and sets and deletes the ‘HTTP_IF_RANGE’ key from the environment. For more information on If-Range see section 14.27. Converts it as a IfRange object.
-
if_unmodified_since
- Gets and sets and deletes the ‘HTTP_IF_UNMODIFIED_SINCE’ key from the environment. For more information on If-Unmodified-Since see section 14.28. Converts it as a HTTP date.
-
is_xhr
Returns a boolean if X-Requested-With is present and XMLHttpRequest
Note: this isn’t set by every XMLHttpRequest request, it is
only set if you are using a Javascript library that sets it
(or you set the header yourself manually). Currently
Prototype and jQuery are known to set this header.
-
make_body_seekable()
This forces environ['wsgi.input'] to be seekable. That
is, if it doesn’t have a seek method already, the content is
copied into a StringIO or temporary file.
The choice to copy to StringIO is made from
self.request_body_tempfile_limit
-
max_forwards
- Gets and sets and deletes the ‘HTTP_MAX_FORWARDS’ key from the environment. For more information on Max-Forwards see section 14.31. Converts it as a int.
-
method
- Gets and sets and deletes the ‘REQUEST_METHOD’ key from the environment.
-
params
- Like .str_params, but may decode values and keys
-
path
- The path of the request, without host or query string
-
path_info
- Gets and sets and deletes the ‘PATH_INFO’ key from the environment.
-
path_info_peek()
- Returns the next segment on PATH_INFO, or None if there is no
next segment. Doesn’t modify the environment.
-
path_info_pop()
‘Pops’ off the next segment of PATH_INFO, pushing it onto
SCRIPT_NAME, and returning the popped segment. Returns None if
there is nothing left on PATH_INFO.
Does not return '' when there’s an empty segment (like
/path//path); these segments are just ignored.
-
path_qs
- The path of the request, without host but with query string
-
path_url
- The URL including SCRIPT_NAME and PATH_INFO, but not QUERY_STRING
-
postvars
- Wraps a decorator, with a deprecation warning or error
-
pragma
- Gets and sets and deletes the ‘HTTP_PRAGMA’ key from the environment. For more information on Pragma see section 14.32.
-
query_string
- Gets and sets and deletes the ‘QUERY_STRING’ key from the environment.
-
queryvars
- Wraps a decorator, with a deprecation warning or error
-
range
- Gets and sets and deletes the ‘HTTP_RANGE’ key from the environment. For more information on Range see section 14.35. Converts it as a Range object.
-
referer
- Gets and sets and deletes the ‘HTTP_REFERER’ key from the environment. For more information on Referer see section 14.36.
-
referrer
- Gets and sets and deletes the ‘HTTP_REFERER’ key from the environment. For more information on Referer see section 14.36.
-
relative_url(other_url, to_application=False)
Resolve other_url relative to the request URL.
If to_application is True, then resolve it relative to the
URL with only SCRIPT_NAME
-
remote_addr
- Gets and sets and deletes the ‘REMOTE_ADDR’ key from the environment.
-
remote_user
- Gets and sets and deletes the ‘REMOTE_USER’ key from the environment.
Remove headers that make the request conditional.
These headers can cause the response to be 304 Not Modified,
which in some cases you may not want to be possible.
This does not remove headers like If-Match, which are used for
conflict detection.
-
scheme
- Gets and sets and deletes the ‘wsgi.url_scheme’ key from the environment.
-
script_name
- Gets and sets and deletes the ‘SCRIPT_NAME’ key from the environment.
-
server_name
- Gets and sets and deletes the ‘SERVER_NAME’ key from the environment.
-
server_port
- Gets and sets and deletes the ‘SERVER_PORT’ key from the environment. Converts it as a int.
-
str_GET
- Return a MultiDict containing all the variables from the
QUERY_STRING.
-
str_POST
Return a MultiDict containing all the variables from a form
request. Returns an empty dict-like object for non-form
requests.
Form requests are typically POST requests, however PUT requests
with an appropriate Content-Type are also supported.
-
str_cookies
- Return a plain dictionary of cookies as found in the request.
-
str_params
- A dictionary-like object containing both the parameters from
the query string and request body.
-
str_postvars
- Wraps a decorator, with a deprecation warning or error
-
str_queryvars
- Wraps a decorator, with a deprecation warning or error
-
url
- The full request URL, including QUERY_STRING
-
urlargs
Return any positional variables matched in the URL.
Takes values from environ['wsgiorg.routing_args'].
Systems like routes set this value.
-
urlvars
Return any named variables matched in the URL.
Takes values from environ['wsgiorg.routing_args'].
Systems like routes set this value.
-
user_agent
- Gets and sets and deletes the ‘HTTP_USER_AGENT’ key from the environment. For more information on User-Agent see section 14.43.
-
class webob.Response(body=None, status=None, headerlist=None, app_iter=None, request=None, content_type=None, conditional_response=(No Default), **kw)
Represents a WSGI response
-
accept_ranges
- Gets and sets and deletes they header Accept-Ranges from the headers For more information on Accept-Ranges see section 14.5.
-
age
- Gets and sets and deletes they header Age from the headers For more information on Age see section 14.6. Converts it as a int.
-
allow
- Gets and sets and deletes they header Allow from the headers For more information on Allow see section 14.7. Converts it as a list.
-
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)
-
app_iter_range(start, stop)
- Return a new app_iter built from the response app_iter, that
serves up only the given start:stop range.
-
body
- The body of the response, as a str. This will read in the
entire app_iter if necessary.
-
body_file
- Returns 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_control
- Get/set/modify the Cache-Control header (section 14.9)
-
charset
- Get/set the charset (in the Content-Type)
-
conditional_response_app(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)
-
content_encoding
- Gets and sets and deletes they header Content-Encoding from the headers For more information on Content-Encoding see section 14.11.
-
content_language
- Gets and sets and deletes they header Content-Language from the headers For more information on Content-Language see section 14.12. Converts it as a list.
-
content_length
- Gets and sets and deletes they header Content-Length from the headers For more information on Content-Length see section 14.17. Converts it as a int.
-
content_location
- Gets and sets and deletes they header Content-Location from the headers For more information on Content-Location see section 14.14.
-
content_md5
- Gets and sets and deletes they header Content-MD5 from the headers For more information on Content-MD5 see section 14.14.
-
content_range
- Gets and sets and deletes they header Content-Range from the headers For more information on Content-Range see section 14.16. Converts it as a ContentRange object.
-
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.
-
content_type_params
- Returns a dictionary of all the parameters in the content type.
-
copy()
- Makes a copy of the response
-
date
- Gets and sets and deletes they header Date from the headers For more information on Date see section 14.18. Converts it as a HTTP date.
-
delete_cookie(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.
-
encode_content(encoding='gzip')
- Encode the content with the given encoding (only gzip and
identity are supported).
-
environ
- Get/set the request environ associated with this response, if
any.
-
etag
- Gets and sets and deletes they header ETag from the headers For more information on ETag see section 14.19.
-
expires
- Gets and sets and deletes they header Expires from the headers For more information on Expires see section 14.21. Converts it as a HTTP date.
- The list of response headers
- The headers in a dictionary-like object
-
last_modified
- Gets and sets and deletes they header Last-Modified from the headers For more information on Last-Modified see section 14.29. Converts it as a HTTP date.
-
location
Retrieve the Location header of the response, or None if there
is no header. If the header is not absolute and this response
is associated with a request, make the header absolute.
For more information see section 14.30.
-
md5_etag(body=None, set_content_md5=False, set_conditional_response=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
If set_conditional_response is True sets self.conditional_response to True
-
pragma
- Gets and sets and deletes they header Pragma from the headers For more information on Pragma see section 14.32.
-
request
- Return the request associated with this response if any.
-
retry_after
- Gets and sets and deletes they header Retry-After from the headers For more information on Retry-After see section 14.37. Converts it as a HTTP date or delta seconds.
-
server
- Gets and sets and deletes they header Server from the headers For more information on Server see section 14.38.
-
set_cookie(key, value='', max_age=None, path='/', domain=None, secure=None, httponly=False, version=None, comment=None, expires=None)
- Set (add) a cookie for the response
-
status
- The status string
-
status_int
- The status as an integer
-
unicode_body
- Get/set the unicode value of the body (using the charset of the Content-Type)
-
unset_cookie(key)
- 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.
-
vary
- Gets and sets and deletes they header Vary from the headers For more information on Vary see section 14.44. Converts it as a list.
-
webob.html_escape(s)
HTML-escape a string or object
This converts any non-string objects passed into it to strings
(actually, using unicode()). All values returned are
non-unicode strings (using &#num; entities for all non-ASCII
characters).
None is treated specially, and returns the empty string.
-
webob.timedelta_to_seconds(td)
- Converts a timedelta instance to seconds.
-
class webob.FakeCGIBody(vars)
-
class webob.ResponseBodyFile(response)
-
encoding
- The encoding of the file (inherited from response.charset)
-
class webob.AppIterRange(app_iter, start, stop)
- Wraps an app_iter, returning just a range of bytes
-
webob._rfc_reference(header, section)
-
webob._cgi_FieldStorage__repr__patch(self)
monkey patch for FieldStorage.__repr__
Unbelievely, the default __repr__ on FieldStorage reads
the entire file content instead of being sane about it.
This is a simple replacement that doesn’t do that
webob.acceptparse
-
class webob.acceptparse.Accept(header_name, header_value)
Represents a generic Accept-* style header.
This object should not be modified. To add items you can use
accept_obj + 'accept_thing' to get a new object
-
best_match(matches, default_match=None)
Returns the best match in the sequence of matches.
The sequence can be a simple sequence, or you can have
(match, server_quality) items in the sequence. If you
have these tuples then the client quality is multiplied by the
server_quality to get a total.
default_match (default None) is returned if there is no intersection.
-
best_matches(fallback=None)
- Return all the matches in order of quality, with fallback (if
given) at the end.
-
first_match(matches)
- Returns the first match in the sequences of matches that is
allowed. Ignores quality. Returns the first item if nothing
else matches; or if you include None at the end of the match
list then that will be returned.
-
quality(match)
- Return the quality of the given match. Returns None if there
is no match (not 0).
-
class webob.acceptparse.NilAccept(header_name)
Represents an Accept header with no value.
-
MasterClass
- alias of Accept
-
class webob.acceptparse.NoAccept(header_name)
-
class webob.acceptparse.MIMEAccept(header_name, header_value)
Represents the Accept header, which is a list of mimetypes.
This class knows about mime wildcards, like image/*
-
accept_html()
- Returns true if any HTML-like type is accepted
-
class webob.acceptparse.MIMENilAccept(header_name)
-
MasterClass
- alias of MIMEAccept
-
webob.acceptparse.parse_accept(value)
Parses an Accept-* style header.
A list of [(value, quality), ...] is returned. quality
will be 1 if it was not given.
webob.byterange
-
class webob.byterange.Range(ranges)
Represents the Range header.
This only represents bytes ranges, which are the only kind
specified in HTTP. This can represent multiple sets of ranges,
but no place else is this multi-range facility supported.
-
static bytes_to_python_ranges(ranges, length=None)
Converts the list-of-ranges from parse_bytes() to a Python-style
list of ranges (non-inclusive end points)
In the list of ranges, the last item can be None to indicate that
it should go to the end of the file, and the first item can be
negative to indicate that it should start from an offset from the
end. If you give a length then this will not occur (negative
numbers and offsets will be resolved).
If length is given, and any range is not value, then None is
returned.
-
content_range(length)
Works like range_for_length; returns None or a ContentRange object
You can use it like:
response.content_range = req.range.content_range(response.content_length)
Though it’s still up to you to actually serve that content range!
-
classmethod parse(header)
- Parse the header; may return None if header is invalid
-
static parse_bytes(header)
Parse a Range header into (bytes, list_of_ranges). Note that the
ranges are inclusive (like in HTTP, not like in Python
typically).
Will return None if the header is invalid
-
static python_ranges_to_bytes(ranges)
Converts a Python-style list of ranges to what serialize_bytes
expects.
This is the inverse of bytes_to_python_ranges
-
range_for_length(length)
If there is only one range, and if it is satisfiable by
the given length, then return a (begin, end) non-inclusive range
of bytes to serve. Otherwise return None
If length is None (unknown length), then the resulting range
may be (begin, None), meaning it should be served from that
point. If it’s a range with a fixed endpoint we won’t know if
it is satisfiable, so this will return None.
-
satisfiable(length)
- Returns true if this range can be satisfied by the resource
with the given byte length.
-
static serialize_bytes(units, ranges)
- Takes the output of parse_bytes and turns it into a header
-
class webob.byterange.ContentRange(start, stop, length)
Represents the Content-Range header
This header is start-stop/length, where stop and length can be
* (represented as None in the attributes).
-
classmethod parse(value)
- Parse the header. May return None if it cannot parse.
webob.cachecontrol
Represents the Cache-Control header
-
class webob.cachecontrol.exists_property(prop, type=None)
- Represents a property that either is listed in the Cache-Control
header, or is not listed (has no value)
-
class webob.cachecontrol.value_property(prop, default=None, none=None, type=None)
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
class webob.cachecontrol.CacheControl(properties, type)
Represents the Cache-Control header.
By giving a type of 'request' or 'response' you can
control what attributes are allowed (some Cache-Control values
only apply to requests or responses).
-
copy()
- Returns a copy of this object.
-
max_age
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
max_stale
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
min_fresh
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
must_revalidate
- Represents a property that either is listed in the Cache-Control
header, or is not listed (has no value)
-
no_cache
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
no_store
- Represents a property that either is listed in the Cache-Control
header, or is not listed (has no value)
-
no_transform
- Represents a property that either is listed in the Cache-Control
header, or is not listed (has no value)
-
only_if_cached
- Represents a property that either is listed in the Cache-Control
header, or is not listed (has no value)
-
classmethod parse(header, updates_to=None, type=None)
Parse the header, returning a CacheControl object.
The object is bound to the request or response object
updates_to, if that is given.
-
private
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
proxy_revalidate
- Represents a property that either is listed in the Cache-Control
header, or is not listed (has no value)
-
public
- Represents a property that either is listed in the Cache-Control
header, or is not listed (has no value)
-
s_max_age
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
s_maxage
Represents a property that has a value in the Cache-Control header.
When no value is actually given, the value of self.none is returned.
-
webob.cachecontrol.serialize_cache_control(properties)
webob.datastruct
Contains some data structures.
An object that represents the headers as present in a
WSGI environment.
This object is a wrapper (with no internal state) for a WSGI
request object, representing the CGI-style HTTP_* keys as a
dictionary. Because a CGI environment can only hold one value for
each key, this dictionary is single-valued (unlike outgoing
headers).
webob.etag
Does parsing of ETag-related headers: If-None-Matches, If-Matches
Also If-Range parsing
mod:webob.exc
HTTP Exception
This module processes Python exceptions that relate to HTTP exceptions
by defining a set of exceptions, all subclasses of HTTPException.
Each exception, in addition to being a Python exception that can be
raised and caught, is also a WSGI application and webob.Response
object.
This module defines exceptions according to RFC 2068 : codes with
100-300 are not really errors; 400’s are client errors, and 500’s are
server errors. According to the WSGI specification , the application
can call start_response more then once only under two conditions:
(a) the response has not yet been sent, or (b) if the second and
subsequent invocations of start_response have a valid exc_info
argument obtained from sys.exc_info(). The WSGI specification then
requires the server or gateway to handle the case where content has been
sent and then an exception was encountered.
- Exception
- HTTPException
- HTTPOk
- 200 - HTTPOk
- 201 - HTTPCreated
- 202 - HTTPAccepted
- 203 - HTTPNonAuthoritativeInformation
- 204 - HTTPNoContent
- 205 - HTTPResetContent
- 206 - HTTPPartialContent
- HTTPRedirection
- 300 - HTTPMultipleChoices
- 301 - HTTPMovedPermanently
- 302 - HTTPFound
- 303 - HTTPSeeOther
- 304 - HTTPNotModified
- 305 - HTTPUseProxy
- 306 - Unused (not implemented, obviously)
- 307 - HTTPTemporaryRedirect
- HTTPError
- HTTPClientError
- 400 - HTTPBadRequest
- 401 - HTTPUnauthorized
- 402 - HTTPPaymentRequired
- 403 - HTTPForbidden
- 404 - HTTPNotFound
- 405 - HTTPMethodNotAllowed
- 406 - HTTPNotAcceptable
- 407 - HTTPProxyAuthenticationRequired
- 408 - HTTPRequestTimeout
- 409 - HTTPConflict
- 410 - HTTPGone
- 411 - HTTPLengthRequired
- 412 - HTTPPreconditionFailed
- 413 - HTTPRequestEntityTooLarge
- 414 - HTTPRequestURITooLong
- 415 - HTTPUnsupportedMediaType
- 416 - HTTPRequestRangeNotSatisfiable
- 417 - HTTPExpectationFailed
- HTTPServerError
- 500 - HTTPInternalServerError
- 501 - HTTPNotImplemented
- 502 - HTTPBadGateway
- 503 - HTTPServiceUnavailable
- 504 - HTTPGatewayTimeout
- 505 - HTTPVersionNotSupported
References:
-
webob.exc.no_escape(value)
-
webob.exc.strip_tags(value)
-
class webob.exc.HTTPException(message, wsgi_response)
- Exception used on pre-Python-2.5, where new-style classes cannot be used as
an exception.
-
class webob.exc.WSGIHTTPException(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPError(detail=None, headers=None, comment=None, body_template=None, **kw)
base class for status codes in the 400’s and 500’s
This is an exception which indicates that an error has occurred,
and that any work in progress should not be committed. These are
typically results in the 400’s and 500’s.
-
class webob.exc.HTTPRedirection(detail=None, headers=None, comment=None, body_template=None, **kw)
base class for 300’s status code (redirections)
This is an abstract base class for 3xx redirection. It indicates
that further action needs to be taken by the user agent in order
to fulfill the request. It does not necessarly signal an error
condition.
-
class webob.exc.HTTPOk(detail=None, headers=None, comment=None, body_template=None, **kw)
- Base class for the 200’s status code (successful responses)
-
class webob.exc.HTTPCreated(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPAccepted(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPNonAuthoritativeInformation(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPNoContent(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPResetContent(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPPartialContent(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPMultipleChoices(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)
-
class webob.exc.HTTPMovedPermanently(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)
-
class webob.exc.HTTPFound(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)
-
class webob.exc.HTTPSeeOther(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)
-
class webob.exc.HTTPNotModified(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPUseProxy(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)
-
class webob.exc.HTTPTemporaryRedirect(detail=None, headers=None, comment=None, body_template=None, location=None, add_slash=False)
-
class webob.exc.HTTPClientError(detail=None, headers=None, comment=None, body_template=None, **kw)
base class for the 400’s, where the client is in error
This is an error condition in which the client is presumed to be
in-error. This is an expected problem, and thus is not considered
a bug. A server-side traceback is not warranted. Unless specialized,
this is a ‘400 Bad Request’
-
class webob.exc.HTTPBadRequest(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPUnauthorized(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPPaymentRequired(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPForbidden(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPNotFound(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPMethodNotAllowed(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPNotAcceptable(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPProxyAuthenticationRequired(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPRequestTimeout(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPConflict(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPGone(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPLengthRequired(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPPreconditionFailed(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPRequestEntityTooLarge(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPRequestURITooLong(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPUnsupportedMediaType(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPRequestRangeNotSatisfiable(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPExpectationFailed(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPUnprocessableEntity(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPLocked(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPFailedDependency(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPServerError(detail=None, headers=None, comment=None, body_template=None, **kw)
base class for the 500’s, where the server is in-error
This is an error condition in which the server is presumed to be
in-error. This is usually unexpected, and thus requires a traceback;
ideally, opening a support ticket for the customer. Unless specialized,
this is a ‘500 Internal Server Error’
-
class webob.exc.HTTPInternalServerError(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPNotImplemented(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPBadGateway(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPServiceUnavailable(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPGatewayTimeout(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPVersionNotSupported(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPInsufficientStorage(detail=None, headers=None, comment=None, body_template=None, **kw)
-
class webob.exc.HTTPExceptionMiddleware(application)
Middleware that catches exceptions in the sub-application. This
does not catch exceptions in the app_iter; only during the initial
calling of the application.
This should be put very close to applications that might raise
these exceptions. This should not be applied globally; letting
expected exceptions raise through the WSGI stack is dangerous.
webob.multidict
Gives a multi-value dictionary object (MultiDict) plus several wrappers
-
class webob.multidict.MultiDict(*args, **kw)
An ordered dictionary that can have multiple values for each key.
Adds the methods getall, getone, mixed, and add to the normal
dictionary interface.
-
add(key, value)
- Add the key and value, not overwriting any previous value.
-
dict_of_lists()
- Returns a dictionary where each key is associated with a
list of values.
-
classmethod from_fieldstorage(fs)
- Create a dict from a cgi.FieldStorage instance
-
getall(key)
- Return a list of all values matching the key (may be an empty list)
-
getone(key)
- Get one value matching the key, raising a KeyError if multiple
values were found.
-
mixed()
- Returns a dictionary where the values are either single
values, or a list of values when a key/value appears more than
once in this dictionary. This is similar to the kind of
dictionary often used to represent the variables in a web
request.
-
classmethod view_list(lst)
- Create a dict that is a view on the given list
-
class webob.multidict.UnicodeMultiDict(multi=None, encoding=None, errors='strict', decode_keys=False)
A MultiDict wrapper that decodes returned values to unicode on the
fly. Decoding is not applied to assigned values.
The key/value contents are assumed to be str/strs or
str/FieldStorages (as is returned by the paste.request.parse_
functions).
Can optionally also decode keys when the decode_keys argument is
True.
FieldStorage instances are cloned, and the clone’s filename
variable is decoded. Its name variable is decoded when decode_keys
is enabled.
-
add(key, value)
- Add the key and value, not overwriting any previous value.
-
dict_of_lists()
- Returns a dictionary where each key is associated with a
list of values.
-
getall(key)
- Return a list of all values matching the key (may be an empty list)
-
getone(key)
- Get one value matching the key, raising a KeyError if multiple
values were found.
-
mixed()
- Returns a dictionary where the values are either single
values, or a list of values when a key/value appears more than
once in this dictionary. This is similar to the kind of
dictionary often used to represent the variables in a web
request.
-
class webob.multidict.NestedMultiDict(*dicts)
- Wraps several MultiDict objects, treating it as one large MultiDict
-
class webob.multidict.NoVars(reason=None)
Represents no variables; used when no variables
are applicable.
This is read-only
webob.statusreasons
Gives status_reasons, a dictionary of HTTP reasons for integer status codes
webob.updatedict
Dict that has a callback on all updates
-
class webob.updatedict.UpdateDict