In PyXWF, we call all content we send over the wire a Message. Messages thus contain information about their mime type, encoding and of course their payload.
They represent it internally however they like, but must be able to serialize the payload to a properly encoded bytes object for conversion in a MessageInfo instance.
Represent an HTML message. doctree must be a valid HTML document tree (the same as the XHTML tree, but without namespaces) as lxml.etree node. Conversion to bytes payload is handled by this class automatically.
You can specify the HTML version via version, which is currently restricted to HTML5.
Return an HTMLMessage instance from the given XHTML doctree. This performs automatic conversion by removing the XHTML namespace from all elements. Raises ValueError if a non-xhtml namespace is encountered.
Baseclass for any message. For proper function, messages must implement the get_encoded_body() method.
It handles sending the message in a given transaction context if all properties and methods are set up properly.
mimetype is the MIME type according to RFC 2046.
Represent a plain-text message. contents must be either a string (which must be convertible into unicode using the default encoding) or a unicode instance.
Represent an XHTML message. doctree must be a valid XHTML document tree as lxml.etree node. Conversion to bytes payload is handled by this class automatically.
Represent a generic XML message. doctree must be a valid lxml Element or ElementTree. content_type must specify the MIME type of the document.
If cleanup_namespaces is True, lxml.etree.cleanup_namespaces() will be called on the tree.