5

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?

Boolean
  • 14,266
  • 30
  • 88
  • 129
  • depends on what you want to do, WSGI is very low level you will need to pick a framework to run on top of WSGI, need more information –  Mar 10 '10 at 22:11
  • Actually I just want to write REST web service API's. Currently, I am not concerned about speed, but in the future I might get concerned. – Boolean Mar 10 '10 at 22:17
  • 1) Please define "better" and "preferred". You need to provide criteria; what you're looking for. Better is undefinable without you saying what's important to you. (2) Do not add comments to a question you own. Update the question with your information about REST. Keep the question clear, complete and precise. Don't add comments. – S.Lott Mar 11 '10 at 00:19
  • "I am still confused."? Everyone says use `mod_wsgi`. What's confusing? Please be specific. – S.Lott Mar 11 '10 at 00:19
  • I am confused about @Graham Dumpleton reply. – Boolean Mar 11 '10 at 01:25
  • 1
    Your language is what is confusing. Don't say 'python' if you mean 'mod_python' and don't say 'wsgi' if what you mean is 'mod_wsgi'. WSGI is not mod_wsgi and vice versa. They are not interchangeable terms. Also, the WSGI specification isn't bound to Python 2.6 and nor is mod_wsgi. There may only be Windows mod_wsgi binaries for Python 2.6/3.1 available but if you have the right older Microsoft compiler, you could build it for Python 2.3 through 2.5 on Windows as well. – Graham Dumpleton Mar 11 '10 at 02:30
  • Thanks @Graham Dumpleton, Now I understood it. – Boolean Mar 11 '10 at 03:00
  • Possible duplicate of [mod\_wsgi, mod\_python, or just cgi?](http://stackoverflow.com/questions/3319545/mod-wsgi-mod-python-or-just-cgi) – 200_success Aug 15 '16 at 21:46

6 Answers6

14

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
  • 854,459
  • 170
  • 1,222
  • 1,395
  • 5
    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 Mar 10 '10 at 22:20
5

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
  • 57,726
  • 6
  • 119
  • 134
4

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
  • 776,304
  • 153
  • 1,341
  • 1,358
  • What is the difference between the two. I just want to expose REST web service API's. – Boolean Mar 10 '10 at 22:18
  • @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 Mar 10 '10 at 22:22
  • 4
    mod_wsgi is for running web apps. mod_python is for extending httpd. – Ignacio Vazquez-Abrams Mar 10 '10 at 22:27
3

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
  • 143
  • 4
1

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
  • 400
  • 3
  • 16
0
  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.

Community
  • 1
  • 1
S.Lott
  • 384,516
  • 81
  • 508
  • 779