[Web-SIG] WSGI Open Space @ PyCon.

Sergey Schetinin maluke at gmail.com
Mon Mar 30 18:32:58 CEST 2009


On Mon, Mar 30, 2009 at 18:46, Eric Larson <ionrock at gmail.com> wrote:
> Seeing as this tuple idea is low hanging fruit, I went ahead and
> created a small bit of middleware for making the conversion.
>
> http://bitbucket.org/elarson/pack/wiki/Home
>
> Hope it helps!

If I'm not missing some quirk about some older Python version, it can
be done simpler:


def wsgi2to1(app):
    """
       Adapts WSGI-2 app to WSGI-1.0 interface
    """
    def wrapped(env, sr):
        status, headers, body = app(env)
        sr(status, headers)
        return body
    #@@ peak.util.decorators.rewrap
    return wrapped




# this implements the new interface
def hello_app(env):
    return ('200 OK', [('Content-Type', 'text/plain')], ['hello world'])

# this one conforms to the old one
hello_app_1 = wsgi2to1(hello_app)


More information about the Web-SIG mailing list