January 8, 2009
Release: pywsgi 0.9.0
Filed under: Software Development — Samuel @ 6:45 pm
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)
No comments yet »