Python web frameworks

J

joe jacob

There are a lot of web frameworks for python like django, mod_python,
spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms
of performance and ease of study.
 
J

Jeff

The only one that I have used extensively is Django, which is very
easy to use and quite powerful in the arena for which it was created.
It has a powerful admin interface that automatically generates data
entry forms for content producers and a decent template system. It
has some definite drawbacks, though. The admin interface is difficult
to customize because it was not meant to be customized too much
(Django was written in a newspaper environment, where data needs to go
online quickly and be easily customizable for the next story or next
year's use). It also lacks ajax support.

I understand that Zope has a pretty high learning curve and is
currently in various stages of rewrite.

I don't know much about the others. Turbo gears uses Mochikit, which
hasn't had a new stable release in some time. I prefer jQuery myself.
 
J

Joe Riopel

There are a lot of web frameworks for python like django, mod_python,
spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms
of performance and ease of study.

I wouldn't classify mod_python as a web framework: "Mod_python is an
Apache module that embeds the Python interpreter within the server.".

I haven't used all of the frameworks that you have mentioned, but I
really like what I have seen from Pylons so far.
 
B

BartlebyScrivener

There are a lot of web frameworks for python like django, mod_python,
spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms
of performance and ease of study.

I'm looking at django mainly. I hope the veterans jump in with the
latest on these. The django book (written by the developers) comes out
12/7. Django comes with its own little server so that you don't have
to set up Apache on your desktop to play with it. Configuration is
tricky at first, but what fun to code a web app in Python instead of
looking up php commands all day.

Drafts of the django book are available at the site. I would follow
the examples in the book instead of the tutorial. The tutorial works,
but I seemed to learn more using the examples in the book.

As for performance, see the page on caching. I barely understand the
server dynamics but you can find pages and sites comparing dango
performance to ruby on rails.

http://www.djangoproject.com/documentation/cache/

rd
 
J

Joe Riopel

Django comes with its own little server so that you don't have
to set up Apache on your desktop to play with it.

Pylons too, it's good for development but using the bundled web server
is not recommended for production.
 
B

Bernard

There are a lot of web frameworks for python like django, mod_python,
spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms
of performance and ease of study.

I'm making web apps with CherryPy at work and it's quite good.
the official docs are a bit messy though but they left useful comments
in their code.
 
D

Diez B. Roggisch

12/7. Django comes with its own little server so that you don't have
to set up Apache on your desktop to play with it.

I was rather shocked to learn that django only has this tiny server and does
not come with a stand-alone server and is supposed to run as
mod_python/cgi-driven app through apache.

Which reaps you of all the benefits of standalone servers like connection
pooling & caching data and so forth. Including sessions - I presume they
always go into the db/filesystem as PHP does.

Diez
 
T

Thomas Wittek

Jeff:
I don't know much about the others. Turbo gears uses Mochikit, which
hasn't had a new stable release in some time. I prefer jQuery myself.

You can use jQuery with TurboGears if you develop custom widgets (I do so).
No problem here.
 
P

Paul Boddie

I was rather shocked to learn that django only has this tiny server and does
not come with a stand-alone server and is supposed to run as
mod_python/cgi-driven app through apache.

The standalone server aspect of a large number of Python Web
frameworks typically involves BaseHTTPServer from the standard
library, as far as I've seen, excluding things like Twisted which
aspire to offer production quality server solutions themselves. This
was common back in the old days of Webware, in contrast to Zope which
used Medusa at the time, if I remember correctly.
Which reaps you of all the benefits of standalone servers like connection
pooling & caching data and so forth. Including sessions - I presume they
always go into the db/filesystem as PHP does.

I guess it's a compromise between deployment complexity and benefits
in the above areas, although mod_python should offer some relief in
some of the above areas. What people didn't like about Webware so much
was that run in the recommended way - with a standalone server which
communicated with Web server processes - people had to have separate
long-running processes, which various hosting providers didn't like.

What's most important is that you should be able to switch out one
server technology with another when you reach the limits of the
original, all without having to rewrite your application or do some
major re-plumbing. It does surprise me that mod_python is recommended
for use with Django in the various quick start guides I've read, but I
suppose that lets the developer avoid the issue of migrating up from a
simple server to something more scalable. Not that this should be a
problem, of course.

Paul
 
B

Bruno Desthuilliers

joe jacob a écrit :
There are a lot of web frameworks for python like django, mod_python,
spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms
of performance and ease of study.

As far as I'm concerned, the winners are Django and Pylons (my own
preference going to Pylons).
 
I

Istvan Albert

I was rather shocked to learn that django only has this tiny server and does
not come with a stand-alone server

Alas it is even worse than that, the development server is single
threaded and that can be a big problem when developing sites that make
multiple simultaneous requests at the same time (say if one of those
requests stalls for some reason). It is trivial to add multi threading
via a mixin (takes about two lines of code) but it does not seem to be
a priority to do so.

For large traffic though, Django is better than just about anything
other framework because it is built as multiprocess framework through
mod_python (rather than threaded). So there is no global interpreter
lock, thread switching etc. Django was built based in a real life
heavy duty use scenario, and over the years that really helped with
ironing out the problems.

i.
 
F

Frank Miles

There are a lot of web frameworks for python like django, mod_python,
spyce, turbo gears, Zope, Cherrypy etc. Which one is the best in terms
of performance and ease of study.

Personally I found zope/plone to be very much its own enormously complex world.
Performance was quite sluggish on a less-than-state-of-the-art computer. Part
of my problem was that my particular job didn't really fit with the particular
viewpoint (way of handling data) implicit in these programs. This might not
be the case for you - you'll have to evaluate that for yourself.

In the end I went with Django (hosted by mod_python/apache). Django thankfully
doesn't require that you use their "admin" as the access point for normal users,
though that means it will take more time and thought. It's still comparatively
flexible and straightforward in comparison to zope/plone. There are a few things
that I am not 100% satisifed with, but overall I have found django to be very
adaptible to my particular needs. All this despite the fact that this is a
pretty minor part of my work - I am pretty much a newby at developing for the web.

BTW the book - while still apparently not fully completed - is available for
free on the 'net.

-f
 
J

Jeff

Jeff:


You can use jQuery with TurboGears if you develop custom widgets (I do so).
No problem here.

That's good to know, but I was intending to mean that TurboGears has
built-in support for Mochikit, while Django has no built-in Javascript
or Ajax support.
 
G

Graham Dumpleton

Alas it is even worse than that, the development server is single
threaded and that can be a big problem when developing sites that make
multiple simultaneous requests at the same time (say if one of those
requests stalls for some reason). It is trivial to add multi threading
via a mixin (takes about two lines of code) but it does not seem to be
a priority to do so.

For large traffic though, Django is better than just about anything
other framework because it is built as multiprocess framework through
mod_python (rather than threaded).

This only holds if actually hosted on Apache. As Django these days
supports WSGI interface there is nothing to stop it being run with
other hosting solutions that support WSGI. So, you could host it under
paster or CherryPy WSGI servers. You could even run it under CGI if
you were really desperate using a CGI-WSGI adapter. So, it isn't
strictly correct to say it is as a multiprocess framework specifically
for mod_python, although the developers will admit in the first
instance that they didn't design the internals with multithreading in
mind. That said, there aren't believed to be any multithreading issues
in Django itself at this time.
So there is no global interpreter
lock, thread switching etc.

Use of worker MPM (multiprocess+multithreaded) in Apache in place of
prefork MPM (multiprocess+single threaded) is also still more than
acceptable a solution to hosting Python web applications using either
mod_python or mod_wsgi.

People keep pushing this barrow about the GIL and multithreading being
a huge problem, when in the context of Apache it is isn't, at least
not to the degree people make out. The reason for this is that when
using worker MPM it sill acts as a multi process web server even
though each process is also multithreaded. Within those worker MPM
child processes there is also a lot going on that doesn't involve
Python code nor the GIL, for example initial request process and
serving up of static files etc.

Result is that the Python GIL is no impediment when using Apache on
UNIX to making good use of multiple processors or cores, even when
Apache worker MPM is used.

For where I have talked about this before see:
http://blog.dscpl.com.au/2007/09/parallel-python-discussion-and-modwsgi.html

Graham
 
B

BartlebyScrivener

This only holds if actually hosted on Apache. As Django these days
supports WSGI interface there is nothing to stop it being run with
other hosting solutions that support WSGI. So, you could host it under
paster or CherryPy WSGI servers. You could even run it under CGI if
you were really desperate using a CGI-WSGI adapter. So, it isn't
strictly correct to say it is as a multiprocess framework specifically
for mod_python, although the developers will admit in the first
instance that they didn't design the internals with multithreading in
mind. That said, there aren't believed to be any multithreading issues
in Django itself at this time.

People keep pushing this barrow about the GIL and multithreading being
a huge problem, when in the context of Apache it is isn't, at least
not to the degree people make out. The reason for this is that when
using worker MPM it sill acts as a multi process web server even
though each process is also multithreaded. Within those worker MPM
child processes there is also a lot going on that doesn't involve
Python code nor the GIL, for example initial request process and
serving up of static files etc.

Result is that the Python GIL is no impediment when using Apache on
UNIX to making good use of multiple processors or cores, even when
Apache worker MPM is used.

I understand about a fifth of this exchange but I'm glad it's here so
I can follow links and search on the terminology. I couldn't tell from
earlier posts if mod_python was good or bad.

The Django book says: "Apache with mod_python currently is the most
robust setup for using Django on a production server."

Is that true? And if you start small with, say, an online arts
magazine for a metropolitan area, then can we easily scale if we
become popular? I'm picking Django because it sounds like they did
just this with a newspaper site in Lawrence, Kansas.

We are thinking of starting with Webfaction and just seeing what
happens. All I know is that I like Python and Django and would rather
stick with open source.

Thanks for the info.

rd
 
G

Graham Dumpleton

I understand about a fifth of this exchange but I'm glad it's here so
I can follow links and search on the terminology. I couldn't tell from
earlier posts if mod_python was good or bad.

Version 3.3 of mod_python fixed up a lot of issues that existed with
older versions of mod_python. There are still a lot of issues in
mod_python unfixed.

https://issues.apache.org/jira/browse/MODPYTHON

In the main people will not run into these issues, of if they do, the
incidence of them causing a direct or significant impact is low, or
with people just tolerating the problems.

If you want to be where hosting with Apache is heading, then look at
mod_wsgi (http://www.modwsgi.org) instead. People will say I am biased
because I wrote it, but I was also the main person who did the more
recent work on fixing up mod_python and am more aware than others of
what problems still exist in mod_python.

To be frank, unless some white knight comes along and dives into
mod_python and fixes up the remaining issues, then you probably will
not see any significant future updates to mod_python and it will just
stagnate. I certainly will not be devoting much time to mod_python any
more.

Part of the problem with mod_python is that the code base has grown
over time and is long overdue for a complete rethink, which is in part
what mod_wsgi was about, ie., making the code and configuration a lot
simpler and safer for use in web hosting environments.

Thus mod_wsgi takes aspects of what mod_python does, combining it with
aspects of how FASTCGI solutions work. This gives the option of
embedding a Python application in Apache for maximum speed, or using
daemon processes as means of being able to better separate multiple
applications.

Most importantly, mod_wsgi supports WSGI directly, making it
reasonably trivial to run any Python web framework or application
which supports the WSGI standard.
The Django book says: "Apache with mod_python currently is the most
robust setup for using Django on a production server."

Is that true?

I would say that that is now debatable. Overall mod_wsgi is probably a
better package in terms of what it has to offer. Only thing against
mod_wsgi at this point is peoples willingness to accept something that
is new in conjunction with Linux distributions and web hosting
companies being slow to adopt new packages.

Various people are quite happily using mod_wsgi. Users of mod_wsgi
range from people trying to run it in memory constrained VPS systems,
right up to major sites serving up to between 3-4 million hits a day.

There have been a few odd things come up since the initial release
which have since been fixed, but the core is showing itself to be very
solid.

Graham
 
J

joe jacob

Version 3.3 of mod_python fixed up a lot of issues that existed with
older versions of mod_python. There are still a lot of issues in
mod_python unfixed.

https://issues.apache.org/jira/browse/MODPYTHON

In the main people will not run into these issues, of if they do, the
incidence of them causing a direct or significant impact is low, or
with people just tolerating the problems.

If you want to be where hosting with Apache is heading, then look at
mod_wsgi (http://www.modwsgi.org) instead. People will say I am biased
because I wrote it, but I was also the main person who did the more
recent work on fixing up mod_python and am more aware than others of
what problems still exist in mod_python.

To be frank, unless some white knight comes along and dives into
mod_python and fixes up the remaining issues, then you probably will
not see any significant future updates to mod_python and it will just
stagnate. I certainly will not be devoting much time to mod_python any
more.

Part of the problem with mod_python is that the code base has grown
over time and is long overdue for a complete rethink, which is in part
what mod_wsgi was about, ie., making the code and configuration a lot
simpler and safer for use in web hosting environments.

Thus mod_wsgi takes aspects of what mod_python does, combining it with
aspects of how FASTCGI solutions work. This gives the option of
embedding a Python application in Apache for maximum speed, or using
daemon processes as means of being able to better separate multiple
applications.

Most importantly, mod_wsgi supports WSGI directly, making it
reasonably trivial to run any Python web framework or application
which supports the WSGI standard.



I would say that that is now debatable. Overall mod_wsgi is probably a
better package in terms of what it has to offer. Only thing against
mod_wsgi at this point is peoples willingness to accept something that
is new in conjunction with Linux distributions and web hosting
companies being slow to adopt new packages.

Various people are quite happily using mod_wsgi. Users of mod_wsgi
range from people trying to run it in memory constrained VPS systems,
right up to major sites serving up to between 3-4 million hits a day.

There have been a few odd things come up since the initial release
which have since been fixed, but the core is showing itself to be very
solid.

Graham

Thanks everyone for the response. From the posts I understand that
Django and pylons are the best. By searching the net earlier I got the
same information that Django is best among the frameworks so I
downloaded it and I found it very difficult to configure. I referred
the djangobook. Is pylons better in terms of performance and ease of
study compared to Django.
 
B

Bruno Desthuilliers

joe jacob a écrit :
(snip)
Thanks everyone for the response. From the posts I understand that
Django and pylons are the best. By searching the net earlier I got the
same information that Django is best among the frameworks so I
downloaded it and I found it very difficult to configure.

???

It's been a couple of years since I last used Django, but I don't
remember any specific complexity wrt/ configuration.
 
J

Jeff

joe jacob a écrit :
(snip)


???

It's been a couple of years since I last used Django, but I don't
remember any specific complexity wrt/ configuration.

The only difficulties I have had have been with serving static media.
Specifically, in the differences in setup between the development
environment and production, and setting it up so that I don't have to
make any changes to the code in order to roll out upgrades to a
product.

My employer (a large local newspaper) has been using Django for about
while now. We get a decent amount of traffic and it has scaled very
nicely. The only area where there were any problems was with our
MySQL server; abstracting your DB code with an ORM is not as efficient
as doing your own custom SQL, at least in terms of performance (in
terms of development time, it certainly outweighs the performance hit
in most cases). However, we were running quite a few sites off of
that database at the time, and that had a lot to do with it as well.
 
J

Joe Riopel

Thanks everyone for the response. From the posts I understand that
Django and pylons are the best. By searching the net earlier I got the
same information that Django is best among the frameworks so I
downloaded it and I found it very difficult to configure. I referred
the djangobook. Is pylons better in terms of performance and ease of
study compared to Django.

I have only used Pylons for the simplest of applications (Not because
I don't think it can handle complex applications, but because I am
trying to learn the framework) and find it very easy to configure.
That said, I think it's definitely worth your time to to either give
Pylons a try, or give Django more time.

This thread has been going for only a few days now, and I wouldn't
expect you'd have very intimate knowledge with any framework.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top