[Web-SIG] WSGI Open Space @ PyCon.

Sergey Schetinin maluke at gmail.com
Mon Mar 30 14:43:47 CEST 2009


(Sorry if this is a duplicate message).

> Topic: Return a tuple of (status, headers, body)
> ------------------------------------------------
>
> That is, get rid of the start_response callable. The general consensus
> was that this is a simple, but powerful improvement, which Rack/Jack
> have demonstrated already. The "simplest possible application object"
> would change from this:
>
>   def simple_app(environ, start_response):
>       """Simplest possible application object"""
>       status = '200 OK'
>       response_headers = [('Content-type','text/plain')]
>       start_response(status, response_headers)
>       return ['Hello world!\n']
>
> ...to this:
>
>   def simple_app(environ):
>       """Simplest possible application object"""
>       status = '200 OK'
>       response_headers = [('Content-type','text/plain')]
>       body = ['Hello world!\n']
>       return (status, response_headers, body)

Did you consider a variation that eliminates the start_response but
returns status and headers as first item of the iterable? Considering
how response is usually generated it could save some code in some
cases and wouldn't add any overhead in others, it also has a pleasant
similarity to the HTTP response format:

  def simple_app(environ):
      """Simplest possible application object"""
      status = '200 OK'
      response_headers = [('Content-type','text/plain')]
      yield status, response_headers
      yield 'Hello world!\n'

Anyway, whichever way will be accepted they are easy to adapt to one
another with a decorator.


More information about the Web-SIG mailing list