Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Web gateway interfaces in Python 3

I've finally concluded that I can no longer afford to just hope the ongoing Py3k/WSGI disasterissues will be resolved anytime soon, so I need to get ready to move on.

Unfortunately, my available options don't seem a whole lot better:

  • While I find a few different Python modules for FastCGI scattered around the web, none of them seem to be getting much (if any) attention and/or maintenance, particularly with regard to Python 3.x, and it's difficult to distinguish which, if any, are really viable.
  • Falling all the way back to the built-in CGI module is hardly better than building something myself from scratch (worse, there's an important bug or two in there that may not get attention until Python 3.3).
  • There is no higher sin than handling HTTP directly in a production webapp. And anyway, that's still reinventing the wheel.

Surely somebody out there is deploying webapps on 3.x in production. What gateway interface are you using, with which module/libraries, and why?

like image 244
Nicholas Knight Avatar asked Aug 13 '10 11:08

Nicholas Knight


People also ask

Is WSGI only for Python?

The Web Server Gateway Interface (WSGI, pronounced whiskey or WIZ-ghee) is a simple calling convention for web servers to forward requests to web applications or frameworks written in the Python programming language. The current version of WSGI, version 1.0. 1, is specified in Python Enhancement Proposal (PEP) 3333.

Is WSGI an API?

(Note: although we refer to it as an “application” object, this should not be construed to mean that application developers will use WSGI as a web programming API! It is assumed that application developers will continue to use existing, high-level framework services to develop their applications.

How does WSGI work Python?

The server executes the web app and sends related information and a callback function to the app. The request is processed on the app side, and a response is sent back to the server utilizing the callback function. Sometimes there might be one or more WSGI middlewares between the server and the web app.

What is pep3333?

PEP 3333 – Python Web Server Gateway Interface v1. 0.1 | peps.python.org.


2 Answers

CherryPy 3.2 release candidates support Python 3.X. Because it only supports WSGI at the web server interface layer and not through the whole stack, then you are isolated from issues as to whether WSGI will change. CherryPy has its own internal WSGI server, but also can run under Apache/mod_wsgi with Python 3.1+. See:

http://www.cherrypy.org/wiki/WhatsNewIn32 http://code.google.com/p/modwsgi/wiki/SupportForPython3X

like image 81
Graham Dumpleton Avatar answered Oct 17 '22 16:10

Graham Dumpleton


bottle supports Python 3, but it suffers from the broken stdlib. However, multipart reimplements cgi.FieldStorage and can be used with bottle to build a Python 3 WSGI web app. I just published a demo. For the moment it is just a test, but as far as I can tell it works well.

like image 1
wobsta Avatar answered Oct 17 '22 18:10

wobsta