bsdnerds logo

bsdnerds.org

Experience with python web frameworks

I like Twisted and Nevow from architectural point of view. Twisted is not an appropriate choice if it is supposed to replace apache or to be installed as default server in multi-user servers. It is still a preferred choice to write networked applications and nevow can serve the web frontend to it. Twisted hates threads. Twisted applications are asynchronous based. Still threads are vague in twisted, but there is deferToThread as claimed by the Twsited folks.

I tried out Mod Python, which is just another kind of pain. It is bound to apache and has weak architecture that makes it unpleasure to use.

Should I say, Zope is not simple and that is the problem with Zope.

And python template systems like TAL, Kid are not any better than Nevow’s data,render,pattern design. I hope things will shape up when Nevow starts to work seemlessly with toolkits and frameworks other than Twisted. Nevow developers claim that Nevow works with CGI, mod_python. I had a minimal example of Nevow application running in mod_python, but got struct when trying to implement the URL handling part.

2020 update these days there are many frameworks like:


24 Responses to 'Experience with python web frameworks'


  • Kumaraguru Says:

    Did you try PyBlosxom (http://pyblosxom.sourceforge.net/) or syncato (http://www.syncato.org/).

  • S R. Says:

    For various reasons, I am attached to Nevow style templates. My current work is to find out how twisted.web.distrib and Apache-Nevow integration works. Having collected enough information, proofs I will probably work on a blog that satisfies my needs.

    In case, If I had to replace this blog (wordpress) with someother (possibly written by me), I must copy the content (including comments) and handle 404 errors and map the (non existent) wordpress urls (such as this one and rss feeds) to valid ones.

  • S R. Says:

    An (old) analysis of existing Python web frameworks can be found at http://www.colorstudy.com/docs/shootout.html

  • Stefano M. Says:

    Twisted hates threads for the simple reason that it is adopting the exactly opposite programming model: event driven.
    This is the very reason twisted can be so fast and scalable, because with no threads there is no context switching. This comes at the cost of a completely different (twisted?) view of the way an application is designed and implemented. But instead of “cost” I woud call it “fun”: network programming in event-driven fashion is an amazing experience, which I highly recommend to anyone as a learning opportunity.

  • S R. Says:

    I would like to see a solid scalable implementation of a Twisted application. Really it would be much fun then.

    btw, I have just decided to write a CMS in twisted/nevow for my university project.

  • Says:

    You could also try looking at the PyWebOff: a more recent shootout of the python web application frameworks.

  • Peter B. Says:

    Big Zope fan. You say the reason for not using Zope is simplicity. Well, do you use vi or Emacs? Were they easy to learn?
    Powerful systems are always difficult to learn otherwise they wouldn’t be powerful. Give Zope a try. You don’t have to understand everything to be able to get started.

  • SR. Says:

    Give Zope a try. You don’t have to understand everything to be able to get started.

    I tried TAL (ZPT). I am quite comfortable with nevow now. I feel nevow is much powerful and excellent than ZPT. After I started writing my blog in it, I am feeling enthusiasitic as development is much faster (which I never imagined before starting it). I will replace wordpress (this blog) with my blog in near future!

  • rick Says:

    I would really like to use Twisted. It’s event driven model is very similar to ASP.Net, so I’m sure I’d pick it up. The problem is I’ve never seen a host that runs the Twisted web server, or Mod_Python for that matter. I did find a host that supports Ruby + FastCGI, so that’s why I’m using Ruby on Rails.

  • Lawouach Says:

    Have you tried CherryPy (http://www.cherrypy.org) by any chance?

    Simple design and really close to Python.

  • SR. Says:


    Have you tried CherryPy (http://www.cherrypy.org) by any chance?
    Simple design and really close to Python.

    This is not the right way to develop web apps (my opinion). Logic (thus content) must be totally separate from presentation, which is another reason why I love nevow.

  • Says:

    CherryPy does separate logic from presentation - you can use just about any template system (Cheetah, CherryTemplate, etc.) with it to achieve something very similar to Nevow…

  • SR. Says:

    you can use just about any template system (Cheetah, CherryTemplate, etc.) with it to achieve something very similar to Nevow…

    I don’t think you can easily achieve what Nevow does with these. Nevow xml templates are much better. Though you can simulate xml templates in cheetah/cherrytemplate it is more work for you.

    Just have a look at nevow examples and documentation, to get know how nevow is different from others.

    It’s very easy to give up nevow in the very beginning, but once you get the idea it is really difficult to switch.

    PS: I am writing a proof of concept blog software in nevow (which will eventually replace wordpress)

  • Says:

    The guy has made his decision.. just let him alone..

    I have a totally different story with twisted, I just feel sorry for all people who like me used twisted for a large project, in the end mantainability has become a real problem (with that async way of doing things). I have used nevow some time ago, and for me cherrypy is far better (simplicity rules always), everything is possible with such a tool, for xml I don’t even think in simulate xml templates, you can do it with cElementTree which generate xml easy in no time (not even java is so fast). You would be surprised to know all things you can do with cheetah templates.. So in the end, to each his own.

    Use nevow if it fits your brain but please don’t say this or that thingy is hard to do with tool X just because you don’t know how to do it.

    Cheers.

  • Says:

    Hi. Could you please elaborate a little on the ModPython pains and weak architecture? I’ve been trying it, and even if I get confused, I tend to think it’s in a maturing process.

  • SR. Says:

    rune, ModPy does what it is supposed to do (integrate with apache providing a way to write handlers) and it does that acceptably well. I was talking about ModPy thinking what I had in mind about a web framework should be like..

  • Uwe S. Says:

    Hi. Did you try Webware or Quixote ? Both are powerful and easy to use.

  • Radek S. Says:

    I have recently done my research among python tools for web apps aswell. And with the similar conlusion :-)

    Just imagine you want to split tasks and responsibilities into:

    - gfx design templates
    - language (system texts) localizations
    - business logic
    - data in RDBMS (preferably in any)
    - web server: Apache (preferably any)

    It’s easy e.g. in php, where:

    RDBMS = Pear, or ADODB wrapper
    business logic = php classes
    languages = gettext()
    templates = Smarty

    I have played with mod_python, CherryPy, Zope and some others mentioned in previous posts. Nevow looks promising, if it was just working with Apache.

    Still it is quicker to put things together using php.
    I could not find similar easy way doing that in Python :(

  • ninpo fu Says:

    2 things about Nevow that absolutely rock:

    stan: Dynamically generate xml/html with pure python. :-D

    liveevil: RPC mechanism that makes use of xmlhttprequest, very useful.

  • SR. Says:


    > Nevow looks promising, if it was just working with Apache.
    > Still it is quicker to put things together using php.
    > I could not find similar easy way doing that in Python

    Nevow has experimental (sometimes buggy) implementation of wsgi (wsgi.py in svn nevow). If you are using svn nevow you can easily get nevow working with CGI and apache.

    You can develop with Twisted and deploy in a CGI environment.

  • SR. Says:


    > 2 things about Nevow that absolutely rock:
    > stan: Dynamically generate xml/html with pure python. :-D
    > liveevil: RPC mechanism that makes use of xmlhttprequest, very useful.

    You should be also appreciating Nevow’s XML templates (once your app started get more heat!). With XML templates, you need not go with implementation of Themes for your web apps. All you need to provide is a set of data_* and render_* methods, which the application user (say blog) will use to write his own customized templates without any knowledge about Python.

    More than that I learned more about Design patterns and OO in practical sense only after working with Nevow.

  • sake Says:

    Did you try zope3 ?

  • SR. Says:

    Not yet.

  • SR. Says:

    It’s easy e.g. in php, where:

    RDBMS = Pear, or ADODB wrapper
    business logic = php classes
    languages = gettext()
    templates = Smarty

    RDBMS = DBAPI (adbapi in twisted)
    business logic = python classes
    languages = import gettext
    templates = Nevow

    And yes, it is much powerful in Python.