[Web-SIG] Re: Bill's comments on WSGI draft 1.4

tony at lownds.com tony at lownds.com
Tue Sep 7 05:21:23 CEST 2004


> The other alternative is to check for a 'read()' method as an
alternative
> to iterability, but it leaves open the question of appropriate block
size.  I suppose we could say that this is up to the server.
>

Yes, much simpler, and servers can come up with a good block size.

> But, no matter how the introspection works, it's going to work strongly
against the appearance of simplicity in the examples.  :(
>
>

Here's the tail end of the CGI example.

    result = application(environ, start_response)
    try:
        if hasattr(result, 'read'):
            result = iter(lambda: result.read(BLOCKSIZE), '')
        for data in result:
            write(data)
    finally:
        if hasattr(result,'close'):
            result.close()

-Tony


More information about the Web-SIG mailing list