On Sat, Aug 14, 2010 at 10:56 AM, BrianTheLion <[email protected]> wrote:
> Cheers for that!
>
> I've read the docs and the code, but I'm still confused about certain
> aspects of the response. In particular, what is the purpose of the
> iterable?

The iterator exists to support chunked output. Sometimes parts of the
result are available piecemeal, as when outputing a very large file,
or where the entire calculation can't be in memory simultaneously
(like a huge generated XML file), or when reading over a socket.

WSGI was originally designed in 2005 as a common protocol between web
applications and web servers, because every framework at the time had
its own incompatible server. So the server could send each chunk to
the browser when it was ready, allowing the browser to render it
incrementally.

However, most WSGI servers nowadays do not preserve the chunks but
wait until the entire response is finished. I'm not sure if Pylons
even handles chunked output, or if it waits until the end of the
iteration.

Another purpose of chunked output was to accomodate asynchronous
servers. But the final protocol did not end up being sufficient for
asynchronous servers, due to issues like a not-ready token (which
async servers need but WSGI doesn't define), so it failed in that
sense.

> Is the idea that the total response, as it comes down from
> the application and through the middleware, should be constructed as a
> "stack" (eg, a list) of the individual responses from each WSGI
> application, a stack that gets "flattened" before it gets written out
> the socket?

No.  Middleware doesn't usually append to the response.  Middleware
reformats the response or replaces it completely, as it sees fit. Some
middlewares pass the response through unchanged, if they work only on
the inbound side or only for side effects like logging. A middleware
*could* append to the response, e.g., to insert an HTML footer or
comment, but that's just a subset-case of reformatting the response.

I wrote a history of Pylons and WSGI covering 2005-2008 which you may
find useful.

http://wiki.pylonshq.com/display/pylonscommunity/Pylons+Historical+Timeline

Additionally, you can browse the discussions in the web-sig, the
central board for discussing Python web protocols.

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to