[Web-SIG] Re: Latest WSGI Draft (Phillip J. Eby)
Phillip J. Eby
pje at telecommunity.com
Wed Aug 25 07:22:28 CEST 2004
At 01:00 AM 8/25/04 -0400, Phillip J. Eby wrote:
>At 11:52 PM 8/24/04 -0500, Ian Bicking wrote:
>>I'd be okay if we used a dictionary-like object that enforced these
>>requirements, kind of like rfc822 defines, but that doesn't seem to be
>>the direction WSGI is going.
>
>If there's an implementation already available in the stdlib for 2.2 and
>up, that's not constantly in flux (like the 'email' package), I'd consider
>it. I just *really* don't want another long thread about what the methods
>should be named and what their precise semantics should be. :)
>
>In the meantime, I'm fine with headers remaining as they were in the
>previous draft: i.e. a sequence of tuples.
Hm. Looking at 'email.Message', actually, it has all the semantics needed
for header management, and it looks like the interface at least is stable
across 2.2 and 2.3 (I haven't checked 2.4.)
The code is relatively brief, and I think I'd be okay with using it as the
type for 'headers'. Anybody have any objections? Here's sample usage:
from email.Message import Message
def application(env, start):
headers = Message()
headers.set_type("text/plain")
headers.add_header("Set-Cookie", "CUSTOMER=WILE_E_COYOTE",
path="/foobar")
start("200 OK", headers)("Hello world!")
One of the nice things about it is that it makes it easier to do MIME and
HTTP headers that have parameter info.
More information about the Web-SIG
mailing list