[Web-SIG] WSGI - alternative ideas

angryhicKclown at netscape.net angryhicKclown at netscape.net
Sat Aug 14 19:42:22 CEST 2004

Hi, I've just subscribed to this list, but I've read much of the archives. Python is in dire and immediate need of WSGI.

I think WSGI needs to be essentially very similar to jonpy (jonpy.sf.net), except without the templating. Jonpy exposes an interface very similar to Java servlets, and can run on cgi, fastcgi, and mod_python by changing one line of code. WSGI, I believe, should be a higher-level interface than what has been currently outlined. For Python to succeed as a web language (and I believe that it will), it needs to support the following out of the box:

- a clean servlet interface, see jonpy's Handler classes
- support for a multitude of different platforms easily
- sessions
- database connection pooling
- caching

The syntax for something like this would be as follows:


import wsgi

class MyServlet(wsgi.Servlet): # perhaps a different name than Servlet?
    def handle(self, req, **formargs):



The wsgi module should automatically detect if its running under CGI, mod_python, fastcgi, PyWX, or even IIS ASP with Python activex script or ISAPI. The request args are passed as key=value, unless there are multiple values for one key, in which case the values are passed as a list.

The request object would support sessions via a "req.sessions" dict. WSGI would pick the storage method it uses depending on what platform it is run on.

It would also support a database pool by using a "req.pool" object. I believe it should support pooling of any type of class. Here's an idea for syntax:

req.pool['database'] = (MySQLdb.connect, {'user':'example','passwd':'secret','db':'example'})

And a call to req.pool['database'] would check out a connection to that database, and would be automatically returned at the end of the request.

Or am I taking this at too high a level? Perhaps it should simply clone the cgi module for different platforms (i.e. from wsgi import cgi, from wsgi import mod_python), or, perhaps the wsgi module will expose the same interface as the cgi module, and autodetect the platform and act accordingly.

Thanks for reading,

Peter Hunt

Switch to Netscape Internet Service.
As low as $9.95 a month -- Sign up today at http://isp.netscape.com/register

Netscape. Just the Net You Need.

New! Netscape Toolbar for Internet Explorer
Search from anywhere on the Web and block those annoying pop-ups.
Download now at http://channels.netscape.com/ns/search/install.jsp

More information about the Web-SIG mailing list