[Web-SIG] [ANN] twsgi: asynchronous WSGI implementation for Twisted Web

Gustavo Narea me at gustavonarea.net
Fri Apr 9 23:14:17 CEST 2010


Hello,

Maybe I'm missing something obvious, but if the gateway doesn't support
applications that return write() callables, then it's not WSGI.

A callable that raises an exception does not even count. It's obvious
that they must not raise exceptions -- Then what's the point of
providing the callable?

That said, I *think* it might be OK to disable support for the write()
callable *optionally* on a per application basis. For example, the
gateway could look at the "requires_write" attribute of the application
callable, if any:
"""
def wsgi_app(environ, start_response):
    # ... process the request and return a response....

wsgi_app.requires_write = False
"""

That way, applications which don't use the write() callable can let your
gateway know and thus it won't pass one on.

We could even standardize this (at wsgi.org) so that any WSGI middleware
which wraps an application can expose the "requires_write" attribute of
the wrapped application... As long as such a middleware doesn't use
write() either.

On the other hand, I would avoid using "middleware" in this context for
something specific to your implementation as people will believe it's a
proper WSGI middleware. It'd certainly be *middle*ware, but I'd use
something that is not confusing/misleading, like "filter". This is just
a suggestion.

Cheers,

-- 
Gustavo Narea <xri://=Gustavo>.



More information about the Web-SIG mailing list