Blog Replacement: Language and Framework

8 PM February 16, 2004

The other day I wrote that I planned to use Twisted to build my own blogging software.

This means using Python. There were a few different reasons for choosing Python:

  1. Python has all the necessary Internet connectivity and plenty of interesting packages available.
  2. Python applications tend to be a lot less memory intensive than Java, which means they can be hosted comparatively cheaply. It’s possible to get a full-featured Python app in 8Mb. I’m not sure that Java Hello World runs in 8 Mb these days.
  3. Most importantly, since I’m doing this as a hobby, I plan to enjoy it, and Python is my current pet language.

Having decided on Python, Ian Bicking’s Web Framework Shootout was my next stop. Because I’d like to use Python commercially, I was looking for a framework that a) is already in wide use, b) is well documented, c) can be used to build functionality stunningly quickly (at least, compared to J2EE) and d) would be acceptable to the clients and other developers of the company I work for.

The two frameworks that stand out for me were Twisted and Webware. I suspect that I will find these two frameworks to be approximately equivalent in terms of utility, with Webware more palatable to our developers due to their Servlet/JSP/EJB background. However, I didn’t want to pass up Twisted without having tried it at least once, so Twisted got the guernsey for my first big project, and I’ll use Webware for the next one.

By alang | # | Comments (10)
(Posted to Software Development and Python)

Comments

At 01:44, 17 Feb 2004 Jeffrey Shell wrote:

There are a couple of newer Python web frameworks/systems not in that shootout that may be of interest to you. They're still in development, but even WebWare has yet to hit 1.0 (and may be in the midst of a big restructuring).

The first is pywork ( pywork.sf.net ), a Pull HMVC based system. The Python components I've seen for it are quite clean, and I like the action map - it's very similar to how I structured one Zope application with public Python scripts that called into lower level code (the real controller) and then dispatched to different pages depending on success or failure.

Zope 3 ( dev.zope.org/Zope3/ ) is a rich framework, like Twisted, focusing on delivering a component architecture for web development. Built heavily on configurable views, adapters, and services, it also promotes clear structured Python components. I think a 1.0 release (that may not have Zope's traditional 'through the web' development system in yet) is not far off.

Neither of those are in wide use yet, but they are going to be strong contenders in the near future.

(#)
At 04:21, 17 Feb 2004 Ian Bicking wrote:

Minor note: it's "Webware", not "WebWare". And as a warning, the Shootout is a bit out of date.

Tho me, one of Webware's biggest advantages is that it's simple -- you can have a working application up quickly, and that application can be grown reasonably. It's not as ambitious a framework as many others, but that's also one of its advantages -- it doesn't force you to use any particular MVC layout, any particular templating system, or much of anything else. Sometimes to its detriment (e.g., user handling is generally implemented ad hoc), but often not. Compared to developing in Zope, this feel very freeing (and while Zope3 is something of a reform, it feels like its a matter of making its conceptual weight manageable, not actually reducing that weight).

Anyway, that's my perspective. Webware certainly isn't the only framework that has these qualities, but I think it's a solid and mature foundation.

(#)
At 06:55, 17 Feb 2004 Andrew Barilla wrote:

I rewrote my site in Webware a few months ago and it was amazingly quick and easy, especially when combined with SQLObjects. Unfortunately it crashed Apache every couple days. I couldn't find the problem immediately so I tried to rewrite it in Twisted but unfortunately their website wasn't working at the time. Not a good sign.

Anyway I rewrote it using Perl, CGI::Application and FastCGI just to get it up, running and stable. Python's still my favorite language by far, but I'm not sure if the web frameworks are ready for primetime yet.

(#)
At 07:23, 17 Feb 2004 Alan Green wrote:

I'm fascinated by how distinct kinds of Python Application Servers there are, especially compared to Java, which has Only One True Framework (albeit with many ancilliary libraries and other add-ons.)

I suppose this is due to two properties of Python: first, it's comparatively easy to up and write your own version of almost anything, and second, the core Python development team purposefully doesn't have strong opinions outside the core language.

I'm interested to hear more experiences from others using different frameworks. Will let you know how I go with Twisted.

Ian: thanks for the pointer on spelling Webware. I fixed the post.

(#)
At 09:09, 17 Feb 2004 Ian Bicking wrote:

I know people have sometimes had problems with stability in their Webware applications (though Webware shouldn't be able to crash Apache under any circumstances). It usually seems to involve some issue in a C module which brings down the process -- not really Webware's fault, but the threaded AppServer means that problems aren't well isolated. Twisted is similar, but even worse, since it has a whole class of Python bugs that can bring down your server... though Webware has some of the same problems, only you won't see it as quickly as the thread pool means that wedged threads only reduce the number of available threads (until it goes to zero) -- which is perhaps worse. Zope has the same problem, though in my experience it doesn't happen as often with Zope. Well, in *my* experience it hasn't happened with Webware, I've only heard reports from other people, so maybe it's not that uncommon in Zope (or experienced Zope admins avoid C extensions like the plague). Having a fixed supported version of Python probably helps Zope too.

Several frameworks use multi-process models, which should be more reliable. Mostly because there's better process controls than there are thread controls -- you can kill a dead process, but dead threads haunt you forever. It makes threading in Python really suck. I don't really understand why this has to be so, but I guess operating systems don't support thread control. Or something. I'd be happy with a non-portable way to kill wedged threads -- it's better than what we have now.

Anyway, multiple processes should be more reliable, like mod_python (forked in the Apache process) or SkunkWeb (which has its own forking server separate from Apache, somewhat like Webware). I'd actually be interested in doing this with Webware as well -- though it'd probably come as a side-effect feature of supporting the Web-SIG container interface, which I've meant to do.

Nevertheless, it should be emphasized that there's a lot of people who use Webware on production sites, and have for years, and don't have stability problems. For example, vorbis.com is one of the older public sites, which uses PSP under Webware.

(#)
At 09:24, 17 Feb 2004 soif wrote:

This really seems to be hot topic today. But i really think that there is too much frameworks in fact. Lot of them only have a special template langage, or special behaviour. I don't really know why guys don't try yo adapt their concept to existing framework. ( you can write a MVC in most of them :)

As Ian, i usually run Webware (w/ SQLobjet) that is really a good tool. It dont' try to enforce your mind in a certain way and don't require a lot of learning to do something. (I've been working on Zope 2 years before, that perhaps why i feel free now).

Anyway, i think webware need to be cleaned up. I don't like the COMKit or the Middle kit laying in the app tree. For me a web framework should only handle request/transaction, url handling / argument parsing. That's all. Having separated component pluggeable in webware will be better. I think, the code would be more easy to read / correct / maintain.

And last point, i encounter segfault w/ webware too, but after a little search i discover, that come from MySQLdb not Webware code.

(#)
At 09:31, 17 Feb 2004 soif wrote:

As Ian said, segfault rarely happens in Zope, but i think the main reason, is that a lot of python C module aren't totally thread-safe, and due to the thread model used in Zope this kind of bugs never happens.

(#)
At 15:41, 17 Feb 2004 Ian Bicking wrote:

One of the things that would hopefully come out of Web-SIG is breaking the frameworks up into layers, so there doesn't need to be as much duplication. So when someone wants to experiment with their own MVC layout or whatever else, they can build on solid foundations and won't reinvent the wheel or create an isolated community.

We've only gotten as far as one small step -- creating a CGI-like interface, so that frameworks could be connected to different server environments (CGI, mod_python, threaded server, multi-process server, etc). It's rather fresh, and hasn't been implemented much, and its scope is quite narrow. It doesn't really allow very well for interaction between components, and because it has only a CGI-like interface it means each application still has to parse the input and produce proper output -- which wouldn't be so bad, except you don't want to unparse the input to pass it to another application. Anyway, that's getting into details. It's okay for what it is.

(#)
At 04:00, 18 Feb 2004 John P. Speno wrote:

In case you haven't seen it, there's a new templating system for Twisted called Nevow. Find more info about it here:
http://divmod.org/users/slyphon.twistd/nevow/moin.cgi/

(#)
At 06:58, 18 Feb 2004 Alan Green wrote:

John:

Thanks for the pointer to nevow. Stan looks really neat (as-well-as/in-spite-of being a clever abuse of Python syntax :) and Formless could be quite useful too.

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green