webob – Request/Response objects

Request

class webob.Request(environ=None, environ_getter=None, charset=(No Default), unicode_errors=(No Default), decode_param_names=(No Default), **kw)
The default request implementation

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_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

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/*

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.

Represents the Cache-Control header

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).

Contains some data structures.

class webob.datastruct.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).

Does parsing of ETag-related headers: If-None-Matches, If-Matches

Also If-Range parsing

class webob.etag.ETagMatcher(etags, weak_etags=())
Represents an ETag request. Supports containment to see if an ETag matches. You can also use etag_matcher.weak_contains(etag) to allow weak ETags to match (allowable for conditional GET requests, but not ranges or other methods).
class webob.etag.IfRange(etag=None, date=None)
Parses and represents the If-Range header, which can be an ETag or a date

Response

class webob.Response(body=None, status=None, headerlist=None, app_iter=None, request=None, content_type=None, conditional_response=None, **kw)
Represents a WSGI response
class webob.byterange.ContentRange(start, stop, length)

Represents the Content-Range header

This header is start-stop/length, where start-stop and length can be * (represented as None in the attributes).

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).

Represents the response header list as a dictionary-like object.

class webob.headerdict.HeaderDict(*args, **kw)
Like a MultiDict, this wraps a list. Keys are normalized for case and whitespace.

Misc Functions

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.response.AppIterRange(app_iter, start, stop)
Wraps an app_iter, returning just a range of bytes

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.
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.

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

Dict that has a callback on all updates

class webob.updatedict.UpdateDict

Descriptors

class webob.descriptors.environ_getter(key, default='', default_factory=None, settable=True, deletable=True, doc=None, rfc_section=None)
For delegating an attribute to a key in self.environ.
class webob.descriptors.header_getter(header, default=None, settable=True, deletable=True, doc=None, rfc_section=None)
For delegating an attribute to a header in self.headers
class webob.descriptors.converter(descriptor, getter_converter, setter_converter, convert_name=None, doc=None, converter_args=())
Wraps a descriptor, and applies additional conversions when reading and writing
class webob.descriptors.deprecated_property(descriptor, attr, message, warning=True)
Wraps a descriptor, with a deprecation warning or error

Table Of Contents

Previous topic

WebOb Reference

Next topic

webob.dec – WSGIfy decorator

This Page