Quantcast
Channel: Jkx@home » twisted
Viewing all articles
Browse latest Browse all 4

Python web developpement: the dilemma

$
0
0

There is a bunch of Python based web framework. So much that it’s a really hard choice to do. Most of them came w/ a special templating language, and a different approach.

Dilemma 1

I really think most of the frameworks, have nothing to do with templating. We should give up with that mixOmatic. A framework is a framework not a templating language. So while looking for a good framework, never looks at its templating system, since you should use the one you want. (not the one that come with the framework).

Dilemma 2

The second thing that run me in trouble is the approach. I find about 3 different way to handle requests, and still wondering what is the best choice

Thread approach

Webware has this kind of approach. It maintain a pool of servlets, and use apache as front-end to dispatch to webware server. This approach is really interesting since you can really tweak performance by maintaining the some cached stuff .. By the other side, you have all the drawbacks of this way to using:

  • A lot of python module aren’t thread safe. Even the SQLObject which is normally written in this way have trouble with thread. Phil lost part of the night to discover that SQLO + SQLite run give him a bunch of errors..
  • Really hard to deploy: Since the servlet pool doesn’t support advanced caching, every single servlet load stay loaded all the time. (I want to deploy a bunch of website .. something like 20 .. with low traffic that isn’t the right way)

Mod_Python approach

There is a lot of frameworks that use this way. The one i really enjoy is MP Servlets. The major feature is that it use Apache 2 thread behaviour, so you don’t have to use python threads. This sound really good, and you don’t have to launch a python server on the host. But the major drawback is that there is no way to maintain (or even limit) a pool of objects between request. (This is possible but you need to tweak the apache way to handle request to disable threading for a proceess… and this isn’t a good approach for virtual hosted website).

Twisted approach

Twisted try to fix the thread problem by using a single loop, and async request handling. With that you can:

  • enjoy the python world without thread nightmare
  • desging small dedicated servers

But once again this way have a major drawback has you will be unable to use stuff like SQLObject since Twisted require some specials database connection to avoid locking (remember single loop). And i don’t want to use the old fashiong sql way to build website. Another thing to remember about Twisted is that you need to use apache to proxy the request to the host, and i don’t really think that this way is really pretty for performance.

Conclusion ?

I don’t have a good conclusion. I know Zope can fix some of this problem, but Zope is a too hard to developp / maintain for me. Zope3 tend to be more simple for a lot of ways, but still under developpement, and need a lot of work to learn right now.

Update: Nobody seems to have a decent solution :) Really strange no ?


Viewing all articles
Browse latest Browse all 4

Trending Articles