Format
Instances of this class represent some particular format. This is the entry point for both response and request handling for the format.
The Format class is accessible via the httpencode.format module.
Methods
f __init__(self, name, content_types, type, secure, load, dump_iter, want_unicode=False, choose_mimetype=None, doc=None) ...
- name:
- A nice readable name for the format.
- content_types:
- A list of mime types; the first one will be preferred.
- type:
- A string giving some indication what kind of Python object this produces. 'python' is just a generic python object; other kinds of objects should use the module or class name.
- load, dump_iter:
- load and dump_iter take two arguments -- either a file object or the Python object to be dumped, and then a content type.
- want_unicode:
- if true, then load and dump produce/consume unicode objects
- secure:
- if true, then this format can decode arbitrary strings without having to trust the source
- choose_mimetype:
- if given, this takes a Python object, preferred content type, and header dict and returns the content type
- doc:
- Any extra documentation you want associated with the object
f parse_request(self, environ, trusted=False) ...
Takes the WSGI environment and parses the request for this format, possibly using a shortcut to avoid decoding.
f parse_wsgi_response(self, status, headers, app_iter, trusted=False) ...
Parses the app_iter.
Note: does not call app_iter.close()
f responder(self, data, content_type=None, headers=None) ...
Returns a WSGI application that serves the given data, with an optional explicit content_type and optional additional headers.
See the source for more information.