PyDocs

Nav

Internet Data Handling

BaseHeader

  • BaseHeader(name, value)
Base class for message headers.

Implements generic behavior and provides tools for subclasses.

A subclass must define a classmethod named 'parse' that takes an unfolded
value string and a dictionary as its arguments.  The dictionary will
contain one key, 'defects', initialized to an empty list.  After the call
the dictionary must contain two additional keys: parse_tree, set to the
parse tree obtained from parsing the header, and 'decoded', set to the
string value of the idealized representation of the data from the value.
(That is, encoded words are decoded, and values that have canonical
representations are so represented.)

The defects key is intended to collect parsing defects, which the message
parser will subsequently dispose of as appropriate.  The parser should not,
insofar as practical, raise any errors.  Defects should be added to the
list instead.  The standard header parsers register defects for RFC
compliance issues, for obsolete RFC syntax, and for unrecoverable parsing
errors.

The parse method may add additional keys to the dictionary.  In this case
the subclass must define an 'init' method, which will be passed the
dictionary as its keyword arguments.  The method should use (usually by
setting them as the value of similarly named attributes) and remove all the
extra keys added by its parse method, and then use super to call its parent
class with the remaining arguments and keywords.

The subclass should also make sure that a 'max_count' attribute is defined
that is either None or 1. XXX: need to better define this API.
Members of BaseHeader

d

defects
A tuple of HeaderDefect instances reporting any RFC compliance problems found during parsing.

f

fold
Fold header according to policy.

m

max_count
The maximum number of headers of this type that can have the same name.

n

name
The name of the header (the portion of the field before the ‘:’).
0 Examples
No examples for email.headerregistry/BaseHeader.
See Also
No see-alsos for email.headerregistry/BaseHeader
0 Notes
No notes for BaseHeader