[Email-SIG] API thoughts
Steffen Daode Nurpmeso
sdaoden at googlemail.com
Mon Mar 7 21:06:08 CET 2011
I was never involved in discussions, so that the topics i address
may have been defined for EMAIL 6 already etc.,
but because i've not found anything in the archives of the list
back in 2010 i add yet another feature request which really
worries me.
I find the interface a bit inconsistent in respect to
replace_header() (replaces the first header found), __delitem__()
(drops them all), __setitem__() (appends) in any case.
(I personally would through these __accessor__ things away, they
taste a bit strange when used to access email payload.)
And i would provide a series of functions which can be used
to get/set/modify header fields and bodies:
i would check wether the argument is a list and if, it would mean
"all bodies of a field". This is of course very hard to implement
if it's done gracefully, i.e. with modification-detection,
order-preservation etc.
Another, easier to implement, idea would be (yet) an(other)
iterator which supports in-place editing. Perfect: it could yield
a (to be invented) class which offers methods like .field(),
.bodies() (all [bodies] - maybe even as sub-iterator),
.remove_field() etc...
Doing it like this would offer the possibility to easily detect
in-place editing of header bodies etc...
All of these are just suggestions and my very personal point of
view, of course.
But one thing is true, and that's that it is currently really hard
to remove or replace just one body of a field, especially if there
are multiple bodies for a field.
-- Steffen Daode
More information about the Email-SIG
mailing list