Skip to main content

Decorators for WSGI without start_response and write

Project description

wsgistraw (WSGI without STart_Response And Write) is a tiny Python library that simplifies coding WSGI applications and middleware by removing start_response and write from signatures of functions. This leads to a signature like:

def app(environ):
    return "200 OK", [("Content-Type", "text/plain")], ["Hello World!"]

That is, return a three-tuple of (status, headers, response).

start_response and write are very annoying in WSGI middleware. wsgistraw makes your middleware code cleaner. This is an example of a “lowercase” middleware factory:

@wsgistraw.mid_factory
def lowercase(app):
    def mid(environ):
        status, headers, response = app(environ)
        return status, headers, (s.lower() for s in response)
    return mid

What’s New

Added app_proxy, fixed a couple of inconsistencies with PEP 333.

  • (+) Added public app_proxy class (former _app_proxy, thanks to Ian Bicking)

  • (-) If an app uses write() then app_proxy invokes response.close() after iterating over it

  • (-) If an app hasn’t invoked start_resposnse() before returning then app_proxy forces this invocation by calling response.next()

See Also

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wsgistraw-0.1.1.zip (17.2 kB view hashes)

Uploaded Source

Built Distribution

wsgistraw-0.1.1-py2.4.egg (5.6 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page