David Geller
dg at sponsera.com
Mon Aug 16 22:57:23 EDT 2004
To me, templates and frameworks are two different animals! And you should be able to use one without the other! For what it's worth, here has been my experience: I. Templates -------------- 1. I used (and still do, in one application) simpleTAL from owlfish, which implements zope's ZPT. It works fine, and I had no problems with it. At first, I thought I liked the ZPT way of doing things: it is a flexible templating language which uses "pure" HTML. This would be good for things like WYSIWYG html editors, and the like. However, after using it for awhile, I found several limitations: a. ZPT can *only* be used for html (or xml): NOT for javascript, style sheets or, more generally, anything else. b. while you can do it, the idea of "building up" a complex page comprised of smaller snippets isn't really what ZPT was designed for. It seems like it is designed to build an entire page at once. For some things this is fine; for others, not quite. 2. I discovered Cheetah, and must say, it has met all of my needs. For now, at least, it is my python templating engine of choice. a. Extremely flexible - can be used for *any* text templating, not just pure html/xml code b. Although I haven't benchmarked it, I would suspect it would be quite "fast" - i.e., run at basically python speeds if you pre-compile the templates. I haven't yet had the need to do this - and it seems to work fast enough for my purposes using the cheetah templates directly. c. Cheetah's facilities are way beyond what I have used - basically, I do the bulk of processing in python, and pass very simple variables to the template. In some cases, the template needs to do a little processing (for complex formatting like alternating styles for lines in a table and the like), but for the most part I use it just to substitute variables. The obvious rule: process the actual data in python; display logic, etc. in cheetah, so there is almost a total separation. d. While the cheetah language is not strictly python, it meshes with python in a very natural way. This theoretically makes the designing of templates easy for non-programmer types. Just keep the logic in the templates SIMPLE. 3. There are ****many**** other templating engines out there. I just came across a new one (on me) yesterday: "empy" which is something like a python version of m4 (I think it is slow, though, and not meant for dynamic situations) II. Frameworks -------------- I have checked out several python frameworks. So far, to be honest, I have not found the "one for me". There are some that are obviously very good, but for one reason or another, have problems for my way of doing things. So, I have basically written my own (at least for the time being), which is very very simple, but gets the job done. And it's easy to debug! What I have found for many things out there - they are too complex for their own good! It believe in KISS, and in modularity to the extreme - a framework should not require you to do "everything" their way. The frameworks I have checked out: 1. slither - I really liked this, but doesn't have a "critical mass", and the developers of it don't seem to want to create an environment so it can be supported. Too bad, because with a few changes, I meets my criteria of: simple + powerful. 2. webware - quite good, and quite extensive. Maybe a little complex for my tastes. What I really don't like about it is the need for a separate process - we at the mod_python group believe in apache, so why not have webare run via a mod_python handler directly under apache control, with apache threading, etc? To me, this would make it a far more desirable and reliable system. 3. mod_python servelets - looked at this, and it might be worthwhile, but haven't tried it yet 4. cheerypy - cool, but an entire "religion", requiring a special compilation phase, etc. 5. albatross - might be ok, but it seems to require the use of its own templating language. 6. quixote - I didn't like the "inside-out" approach of embedding html in python. 7. twisted - isn't a framework! But really cool toolkit if you want to do sophisticated web-enabled applications. CONCLUSIONS: 1. Python is wonderful! BUT 2. The world of Python for the Web needs alot of work. Other than Zope, there doesn't seem to be a consensus for what the best way of doing things is! Now, that is a good thing (if "choice" = "good"), but it is also daunting to the newbie, and makes it hard for someone who knows a little more to convince a newbie that Python is the way to go for the web (which it IS, in my opinion, for many situations). 3. I think the python community needs a ..."plan" of some sort, to try to come up with recommendations, tools, basic elements, etc., so new folks might have a much better idea of at least how to get started building web apps in python with a minimum of grief.... My 2 cents... Cheers, David
|