Package openid :: Package yadis :: Module accept
[frames | no frames]

Module openid.yadis.accept

Functions for generating and parsing HTTP Accept: headers for supporting server-directed content negotiation.
Function Summary
  generateAcceptHeader(*elements)
Generate an accept header value
  getAcceptable(accept_header, have_types)
Parse the accept header and return a list of available types in preferred order.
  matchTypes(accept_types, have_types)
Given the result of parsing an Accept: header, and the available MIME types, return the acceptable types with their quality markdowns.
  parseAcceptHeader(value)
Parse an accept header, ignoring any accept-extensions

Function Details

generateAcceptHeader(*elements)

Generate an accept header value

[str or (str, float)] -> str

getAcceptable(accept_header, have_types)

Parse the accept header and return a list of available types in preferred order. If a type is unacceptable, it will not be in the resulting list.

This is a convenience wrapper around matchTypes and parseAcceptHeader.

(str, [str]) -> [str]

matchTypes(accept_types, have_types)

Given the result of parsing an Accept: header, and the available MIME types, return the acceptable types with their quality markdowns.

For example:
>>> acceptable = parseAcceptHeader('text/html, text/plain; q=0.5')
>>> matchTypes(acceptable, ['text/plain', 'text/html', 'image/jpeg'])
[('text/html', 1.0), ('text/plain', 0.5)]
Type signature: ([(str, str, float)], [str]) -> [(str, float)]

parseAcceptHeader(value)

Parse an accept header, ignoring any accept-extensions

returns a list of tuples containing main MIME type, MIME subtype, and quality markdown.

str -> [(str, str, float)]

Generated by Epydoc 2.1 on Fri Dec 14 16:10:52 2007 http://epydoc.sf.net