set_content(msg, obj, *args, **kw)
If the maintype
is multipart
, raise a TypeError
; otherwise look up a handler function based on the type of obj (see next paragraph), call clear_content()
on the msg, and call the handler function, passing through all arguments. The expectation is that the handler will transform and store obj into msg, possibly making other changes to msg as well, such as adding various MIME headers to encode information needed to interpret the stored data.
To find the handler, obtain the type of obj (typ = type(obj)
), and look for the following keys in the registry, stopping with the first one found:
- the type itself (
typ
) - the type’s fully qualified name (
typ.__module__ + '.' + typ.__qualname__
). - the type’s qualname (
typ.__qualname__
) - the type’s name (
typ.__name__
).
If none of the above match, repeat all of the checks above for each of the types in the MRO (typ.__mro__
). Finally, if no other key yields a handler, check for a handler for the key None
. If there is no handler for None
, raise a KeyError
for the fully qualified name of the type.
Also add a MIME-Version header if one is not present (see also MIMEPart
).
Please login to continue.