WSGI Utils

Utility libraries to assist in developing simple WSGI applications.

WSGI Utils are a package of standalone utility libraries that ease the development of simple WSGI programs.  The functionality provided is limited at the moment, patches to add new features and address defects are most welcome.

Example

A simple example of how these utilities can be used together:


from wsgiutils import SessionClient, wsgiAdaptor, wsgiServer
class TestApp:
	def requestHandler (self, request):
		session = request.getSession()
		count = session.get ('counter', 0)
		count += 1
		session ['counter'] = count
		request.sendContent("<html><body><h1>Visits: %s</h1></body></html>" % str (count), 'text/html')
	
testclient = SessionClient.LocalSessionClient('session.dbm', 'testappid')
testadaptor = wsgiAdaptor.wsgiAdaptor (TestApp(), 'siteCookieKey', testclient)
server = wsgiServer.WSGIServer (('localhost', 1088), {'/': testadaptor.wsgiHook})
server.serve_forever()

wsgiServer - API

This module provides a very simple multi-threaded WSGI server implementation based on SimpleHTTPServer from Python's standard library.  Multiple applications can be hosted at different URLs.

wsgiAdaptor - API

A very basic web application framework that works with WSGI compliant servers.  Provides Basic authentication, signed cookies, and persistent sessions  (see SessionClient).

SessionClient - API

This module provides simple session management.  Two implementations are given: LocalSessionClient and SessionServerClient.  The LocalSessionClient class is suitable for use with multi-threaded, single process, long-lived WSGI implementations such as wsgiServer.  SessionServerClient communicates to the SessionServer via Unix domain sockets and is suitable for multi-process WSGI implementations such as CGI.

SessionServer & SessionServerDaemon - API

Listens on a Unix domain socket for connections from a single client and provides session persistance.

Last Modified: Sun, 01 Feb 2015 10:59:33 CET

Made with PubTal 3.5

Copyright 2021 Colin Stewart

Email: colin at owlfish.com