[Web-SIG] PEP 444 (aka Web3)
armin.ronacher at active-4.com
Thu Sep 16 13:32:37 CEST 2010
On 9/16/10 1:23 PM, Dirkjan Ochtman wrote:
> I find the order of the application return arguments really annoying,
> could it just be status, headers, body? Mirrors the actual structure
> of the request, which is easier to remember IMO.
The motivation is that you can pass that to constructors of response
objects already in place.
response_tuple = response.get_response_tuple()
response = Response(*response_tuple)
The order "body", "status code", "headers" is what Werkzeug and WebOb
are currently using. Django has (content, mimetype, status) as
constructor but if they detect a list/dict on the third parameter they
could assume that mimetype referes to the status thus they have a proper
> Also, I would really like it if the header value returned by
> applications must be checked for an .items() method so we can return
> (o)dicts in addition to tuples.
That would be a nice to have, but makes the middleware logic harder
because each middleware would have to check for the type.
> I also keep thinking that some things (for example status) should just
> be allowed to be text, but restricted to ascii.
Works for 2.x, but on 3.x that would mean each middleware would have to
check the type before each operation and convert to bytes if necessary
which means a lot of overhead for each middleware in the stack.
More information about the Web-SIG