Back to index

moin  1.9.0~rc2
Static Public Attributes | Properties | Private Member Functions Class Reference
Inheritance diagram for
Inheritance graph

List of all members.

Static Public Attributes

tuple location
tuple age
tuple content_type
tuple content_length
tuple content_location
tuple content_encoding
tuple content_md5
tuple date
tuple expires
tuple last_modified
tuple vary
tuple content_language
tuple allow



Private Member Functions

def _get_mimetype
def _set_mimetype
def _get_mimetype_params
def _get_retry_after
def _set_retry_after
def _set_property

Detailed Description

A mixin for :class:`BaseResponse` subclasses.  Response objects that
mix this class in will automatically get descriptors for a couple of
HTTP headers with automatic type conversion.

Definition at line 1022 of file

Member Function Documentation

Definition at line 1028 of file

01029     def _get_mimetype(self):
01030         ct = self.headers.get('content-type')
01031         if ct:
01032             return ct.split(';')[0].strip()

Definition at line 1036 of file

01037     def _get_mimetype_params(self):
01038         def on_update(d):
01039             self.headers['Content-Type'] = \
01040                 dump_options_header(self.mimetype, d)
01041         d = parse_options_header(self.headers.get('content-type', ''))[1]
01042         return CallbackDict(d, on_update)

Here is the call graph for this function:

Definition at line 1104 of file

01105     def _get_retry_after(self):
01106         value = self.headers.get('retry-after')
01107         if value is None:
01108             return
01109         elif value.isdigit():
01110             return datetime.utcnow() + timedelta(seconds=int(value))
        return parse_date(value)

Here is the call graph for this function:

Definition at line 1033 of file

01034     def _set_mimetype(self, value):
01035         self.headers['Content-Type'] = get_content_type(value, self.charset)

Here is the call graph for this function:

Definition at line 1129 of file

01130     def _set_property(name, doc=None):
01131         def fget(self):
01132             def on_update(header_set):
01133                 if not header_set and name in self.headers:
01134                     del self.headers[name]
01135                 elif header_set:
01136                     self.headers[name] = header_set.to_header()
01137             return parse_set_header(self.headers.get(name), on_update)
01138         return property(fget, doc=doc)

Here is the call graph for this function:

Definition at line 1111 of file

01112     def _set_retry_after(self, value):
01113         if value is None:
01114             if 'retry-after' in self.headers:
01115                 del self.headers['retry-after']
01116             return
01117         elif isinstance(value, datetime):
01118             value = http_date(value)
01119         else:
01120             value = str(value)
01121         self.headers['Retry-After'] = value

Here is the call graph for this function:

Member Data Documentation

Initial value:
header_property('Age', None, parse_date, http_date, doc='''
    The Age response-header field conveys the sender's estimate of the
    amount of time since the response (or its revalidation) was
    generated at the origin server.

    Age values are non-negative decimal integers, representing time in

Definition at line 1056 of file

Initial value:
_set_property('Allow', doc='''
    The Allow entity-header field lists the set of methods supported
    by the resource identified by the Request-URI. The purpose of this
    field is strictly to inform the recipient of valid methods
    associated with the resource. An Allow header field MUST be
    present in a 405 (Method Not Allowed) response.''')

Definition at line 1149 of file

Initial value:
header_property('Content-Encoding', doc='''
    The Content-Encoding entity-header field is used as a modifier to the
    media-type.  When present, its value indicates what additional content
    codings have been applied to the entity-body, and thus what decoding
    mechanisms must be applied in order to obtain the media-type
    referenced by the Content-Type header field.''')

Definition at line 1078 of file

Initial value:
_set_property('Content-Language', doc='''
     The Content-Language entity-header field describes the natural
     language(s) of the intended audience for the enclosed entity.  Note
     that this might not be equivalent to all the languages used within
     the entity-body.''')

Definition at line 1144 of file

Initial value:
header_property('Content-Length', None, int, str, doc='''
    The Content-Length entity-header field indicates the size of the
    entity-body, in decimal number of OCTETs, sent to the recipient or,
    in the case of the HEAD method, the size of the entity-body that would
    have been sent had the request been a GET.''')

Definition at line 1068 of file

Initial value:
header_property('Content-Location', doc='''
    The Content-Location entity-header field MAY be used to supply the
    resource location for the entity enclosed in the message when that
    entity is accessible from a location separate from the requested
    resource's URI.''')

Definition at line 1073 of file

Initial value:
header_property('Content-MD5', doc='''
     The Content-MD5 entity-header field, as defined in RFC 1864, is an
     MD5 digest of the entity-body for the purpose of providing an
     end-to-end message integrity check (MIC) of the entity-body.  (Note:
     a MIC is good for detecting accidental modification of the
     entity-body in transit, but is not proof against malicious attacks.)

Definition at line 1084 of file

Initial value:
header_property('Content-Type', doc='''
    The Content-Type entity-header field indicates the media type of the
    entity-body sent to the recipient or, in the case of the HEAD method,
    the media type that would have been sent had the request been a GET.

Definition at line 1063 of file

Initial value:
header_property('Date', None, parse_date, http_date, doc='''
    The Date general-header field represents the date and time at which
    the message was originated, having the same semantics as orig-date
    in RFC 822.''')

Definition at line 1091 of file

Initial value:
header_property('Expires', None, parse_date, http_date, doc='''
    The Expires entity-header field gives the date/time after which the
    response is considered stale. A stale cache entry may not normally be
    returned by a cache.''')

Definition at line 1095 of file

Initial value:
header_property('Last-Modified', None, parse_date,
                                    http_date, doc='''
        The Last-Modified entity-header field indicates the date and time at
        which the origin server believes the variant was last modified.''')

Definition at line 1099 of file

Initial value:
header_property('Location', doc='''
    The Location response-header field is used to redirect the recipient
    to a location other than the Request-URI for completion of the request
    or identification of a new resource.''')

Definition at line 1052 of file

Initial value:
_set_property('Vary', doc='''
     The Vary field value indicates the set of request-header fields that
     fully determines, while the response is fresh, whether a cache is
     permitted to use the response to reply to a subsequent request
     without revalidation.''')

Definition at line 1139 of file

Property Documentation

Initial value:
property(_get_mimetype, _set_mimetype, doc='''
    The mimetype (content type without charset etc.)''')

Definition at line 1043 of file

Initial value:
property(_get_mimetype_params, doc='''
    The mimetype parameters as dict.  For example if the content
    type is ``text/html; charset=utf-8`` the params would be
    ``{'charset': 'utf-8'}``.

    .. versionadded:: 0.5

Definition at line 1045 of file

Initial value:
property(_get_retry_after, _set_retry_after, doc='''
    The Retry-After response-header field can be used with a 503 (Service
    Unavailable) response to indicate how long the service is expected
    to be unavailable to the requesting client.

    Time in seconds until expiration or date.''')

Definition at line 1122 of file

The documentation for this class was generated from the following file: