webob -- Request/Response objects¶
Headers¶
Accept-*¶
Parses a variety of Accept-* headers.
These headers generally take the form of:
value1; q=0.5, value2; q=0
Where the q parameter is optional. In theory other parameters
exists, but this ignores them.
-
class
webob.acceptparse.Accept(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(offers, default_match=None)¶ Returns the best match in the sequence of offered types.
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. If two matches have equal weight, then the one that shows up first in the offers list will be returned.But among matches with the same quality the match to a more specific requested type will be chosen. For example a match to text/* trumps /.
default_match (default None) is returned if there is no intersection.
-
static
parse(value)¶ Parse
Accept-*style header.Return iterator of
(value, quality)pairs.qualitydefaults to 1.
-
quality(offer, modifier=1)¶ Return the quality of the given offer. Returns None if there is no match (not 0).
-
Cache-Control¶
-
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.
-
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.
-
update_dict¶ alias of
UpdateDict
-
Misc Functions and Internals¶
-
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.
-
class
webob.headers.ResponseHeaders(*args, **kw)¶ Dictionary view on the response headerlist. Keys are normalized for case and whitespace.
-
class
webob.headers.EnvironHeaders(environ)¶ 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).
-
class
webob.cachecontrol.UpdateDict¶ Dict that has a callback on all updates