[Python-3000] Question about email/generator.py

Barry Warsaw barry at python.org
Fri Oct 26 05:31:28 CEST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Oct 23, 2007, at 5:31 PM, Luke Stebbing wrote:

> On 10/23/07, Barry Warsaw <barry at python.org> wrote:
>> On Oct 23, 2007, at 3:36 PM, Guido van Rossum wrote:
>>> At this point I (Guido) am really hoping someone will want to "own"
>>> this issue and redesign the API properly...
>>
>> I'm really bummed that I've had no time to work on this.  Life and
>> work have imposed.  I'd be willing to chat with someone about what I
>> think should happen.  At this point irc or im might be best. :(
>
> In py2k, you determine whether a payload is 'list of Message' or 'str'
> by calling .is_multipart(). Maybe .is_str() and .is_bytes() methods
> (or properties) could be added. Alternatively, there could be a
> .payload_type property to test against.
>
> Whatever it does, I think it should parallel the polymorphic structure
> used by the new I/O [1]. Does that mean Message ABCs? Would that be
> overkill?
>
> I've been using the email package pretty heavily this year, and I'd be
> up for talking about this on any of the im services or on freenode or
> whatever.

Hi Luke,

I'm actually thinking something along the lines of  
changing .get_payload() to only return the raw payload when the  
content type is scalar.  For non-scalar types (i.e. multiparts),  
you'd get an exception if you tried to use .get_payload().  I'd also  
separate out getting the raw payload and getting the decoded payload  
into separate APIs, either by adding a new .get_decoded_payload() or  
having .get_payload() return a Payload object that knows how to  
decode itself (and return its content type).

Can you talk more about how you think the polymorphism would work?  I  
don't immediately see a parallel, and yeah, I kind of do think that  
message ABCs are overkill (I'd love for whatever we come up with to  
be backward compatible with Python 2.x if at all possible).  The fact  
that .get_decoded_payload() could return bytes or strings is  
bothersome though, so if you have some thoughts about how to do that  
more cleanly, I'm all ears.

Definitely ping me on freenode (nick: barry) any time during working  
hours EST if you want to chat.  I'm almost always on, hanging out in  
#mailman and #launchpad, though that shouldn't matter if you want to  
pvtmsg me.

Cheers,
- -Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (Darwin)

iQCVAwUBRyFfkHEjvBPtnXfVAQJA0gP+PsEBOhInn5ReEwGgD9BeDg12VFkVrDET
UTZlbPpBhDISNvByfvHJXSJMnO1XCmUniA4a7sQ0PHEjdEMHSFY6NKT3BtVRg4yh
WoDIEVs8WIOn2k+tHb2E0SDPQTNtnyA2FbG8CGq27wvGxbd3C61ytylgKofP+0A8
oJHW6atRW7g=
=fNGw
-----END PGP SIGNATURE-----


More information about the Python-3000 mailing list