views:

306

answers:

6

Hi,

I am planning to write web service in python. But, I found wsgi also does the similar thing. Which one can be preferred?

Thank you
Bala

Update

I am still confused. Please help.

Better in my sense means:
1. Bug will be fixed periodically.
2. Chosen by most developers.
3. Additional features like authentication tokens like AWS, can be supported out of the box.
4. No strong dependency on version.( I see that wsgi requires python 2.6)
5. All python libraries will work out of the box.
6. Scalable in the future.
7. Future upgrade don't cause any issues.

With my limited experience, I want these features. There might be some I might be missing.

Thanks
Bala

Update

I am sorry for all the confusion caused. I just want to expose a restful web services in python language. Is there a good framework?

+2  A: 

If you just want to run web apps then use mod_wsgi. If you need to write a handler for the rest of httpd's request/response phases then use mod_python.

Ignacio Vazquez-Abrams
What is the difference between the two. I just want to expose REST web service API's.
Algorist
@Algorist Unless you know you have special requirements that require mod_python, you don't _need_ mod_python. 99% of the time there's no reason to use it on a new project unless you have to run on an existing mod_python-dependent platform.
Nicholas Knight
mod_wsgi is for running web apps. mod_python is for extending httpd.
Ignacio Vazquez-Abrams
+6  A: 

mod_wsgi is more actively maintained and (I hear -- haven't benchmarked them myself!) better performing than mod_python. So unless you need exclusive features of mod_python, just to use a web app framework (or non-framework, like werkzeug;-), you're probably better off with mod_wsgi! (Just about every Python web framework, and many non-frameworks of which werkzeug is my favorite, support WSGI as their standard interface to the web server, these days).

Alex Martelli
Note when Alex says "mod_wsgi is more actively maintained", what he means is "mod_python's last release was in 2007". :) Definitely use mod_wsgi if you can.
Nicholas Knight
+2  A: 

Don't confuse what WSGI and mod_wsgi are. WSGI is an interface specification for hosting Python web applications on a server. The mod_wsgi module is an implementation of the WSGI specification using Apache as the underlying web server. Thus, Python and WSGI are not choices exactly, WSGI is just one way of being able to communicate between a Python web service/application and the web server. The mod_wsgi package is one implementation of that interface. So, WSGI is a means to an end, not a solution in itself.

Personally, I'd very much suggest you just use a minimal Python framework/non framework and as Alex suggests, Werkzeug is a good choice.

Graham Dumpleton
+2  A: 

mod_wsgi is specifically tuned to run Python web apps that use WSGI in Apache. mod_python is for any kind of Python web app, including WSGI apps. mod_wsgi also has a lower memory footprint than mod_python.

drr
A: 
  1. Bug will be fixed periodically.

    Unless you're paying money, you cannot have any idea about this.

  2. Chosen by most developers.

    mod_wsgi

  3. Additional features like authentication tokens like AWS, can be supported out of the box.

    True for every framework.

  4. No strong dependency on version.( I see that wsgi requires python 2.6)

    What? Everything depends on compatible versions. Everything. Every single piece of software.

  5. All python libraries will work out of the box.

    "All?" What about the poorly-written ones?

  6. Scalable in the future.

    Sure. We always hope for this. There's no guarantee.

  7. Future upgrade don't cause any issues.

    That's funny.

"I want these features."

We all do. Realistically, you can get #2. The rest don't make sense or cannot every be assured.

S.Lott
+1  A: 

mod_wsgi is much more actively maintained than mod_python at this point. It also has a good bit of momentum, as it was somewhat recently adopted as the preferred deployment method on apache2 by Django. The author is also actively engaged with the Python community in regards to the future evolution of WSGI.

Greg