On 5 March 2010 06:45, AnotherNetFellow <[email protected]> wrote:
> Hi,
>
> today I found that Google App Engine applications are working with
> wsgiref. So, i'm new to wsgi world.
>
> On wsgi.org i read that mod_wsgi (for apache) and wsgiref (python
> module) are alternatives. Module wsgiref also includes a CGI gateway
> that can make it working with every server that supports CGI
> applications.
>
> Ok, the question is: what is the difference? wsgiref is cross-platform
> and server-indipendent. So, why should I use mod_wsgi?
>
> I've been googling for the entire afternoon, but can't find any
> article speaking about this.
>
> Can you please help me?

You are missing the whole point.

WSGI itself is an interface definition and nothing more. There are
many implementations of the WSGI interface and wsgiref and mod_wsgi
are just two options. A WSGI application doesn't need to use wsgiref.
In fact the wsgiref module is simply that, a very simple reference
implementation to illustrate how WSGI works and also contains some
validation tools for determining whether your WSGI application is
behaving correctly in respect of the WSGI interface standard.

In wsgiref there is a simple pure Python implementation of WSGI server
based on simple HTTP server from Python distributions. This is not a
production grade server for various reasons and for GAE to even use
it, they would need to have extended it such that it is wrong and/or
meaningless for them to say they use wsgiref.

The wsgiref module also contains a CGI/WSGI bridge and even if you
need the ability to use WSGI on top of CGI, you don't need to use that
CGI/WSGI implementation. In fact, the WSGI PEP at
'http://www.python.org/dev/peps/pep-0333/' contains a sample CGI/WSGI
bridge as do some other packages as well.

In summary, the implementations of hosting mechanisms are meaningless.
The important thing is the WSGI interface definition itself. You will
find many hosting mechanisms that support that interface. Each has
different qualities and features available and/or work within
different web server environments, or even provide their own web
server. You need to look at what hosting environment you need to work
in and choose the appropriate WSGI hosting implementation that suits.

If you have to use CGI, the the CGI/WSGI bridge in wsgiref is one
option but performance will suffer. If you need to work with nginx,
lighttpd, or Cherokee, then you will want to look at FASTCI based
bridges such as flup, or instead use uWSGI where supported. If you
want standalone Python server, then look at CherryPy WSGI server or
Paste server. If you want to use Apache, you can use mod_wsgi, a WSGI
adapter for mod_python, FASTCGI or uWSGI.

So, many options to choose from. There is no one right solution. So
long as your application conforms to WSGI interface specification, you
can technically use any of them. Whether your application itself
though will work with all is a different matter. By that I mean
performance issues for CGI solutions, and multithreading issues if
using a system which uses threads instead of or in addition to
processes.

You can get a feel for the different process/threading modes
Apache/mod_wsgi alone can operate under by reading:

  http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading

Graham

-- 
You received this message because you are subscribed to the Google Groups 
"modwsgi" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/modwsgi?hl=en.

Reply via email to