8 Jan 2009 knipknap   » (Journeyer)

Release: pywsgi 0.9.0

pywsgi is a brand new and very simple Python module for web applications. Applications using pywsgi will work with WSGI, CGI, and mod_python; the differences between these environments are abstracted. It also handles sessions, cookies, and GET/POST data. It also comes with some useful tools for URL handling.

Some example code is here:

def handler(request):
    # The code of your actual web site is here.
    request.write('Hello World')
    request.start_session()
    for key, value in request.get_data():
        print "GET DATA:", key, value
    for key, value in request.post_data():
        print "POST DATA:", key, value
    for key, value in request.cookies():
        print "COOKIE:", key, value
    for key, value in request.session().data():
        print "SESSION DATA:", key, value

if __name__ == '__main__':
    from pywsgi import RequestHandler
    request_handler = RequestHandler(handler)

The above code will work with both, mod_wsgi and mod_cgi. Note that accessing GET, POST, COOKIE, and SESSION data is completely uniform via a dictionary-like Table object.
This initial release also comes with complete API documentation.

Links:
Download
Project page
API documentation
Handbook (PDF, incomplete)

Syndicated 2009-01-08 17:45:12 from Debain.org

Latest blog entries     Older blog entries

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!