Just kidding (TurboGears template language vs the old-code mess...)


Okay, I've officially gone way over my time for the day. I wanted to see if I could use a templating language to clean up some of the old-code cruft without having the project's owner have a heart attack. A good bit of time was spent trying to get kid installed. It uses a Python egg, and that screwed up rather royally when I tried to install (as I normally do) into an unprivileged directory. In the end I just grabbed the kid directory and moved it into my Python working directory.

Once I got the package installed, it worked as advertised. Nothing particularly complex, it looks basically like TAL or Nevow in terms of the approach. The ability to use ${value} does make attribute generation easier than in TAL.

It doesn't seem to have as elegant a pattern for site-wide styles and the like as I'd like. You can define a layout template that rewrites elements in the final template, but it doesn't quite feel built-in, more of an "oh, we could do that with this" feel. Still, it looks functional... I just miss being able to write an overarching template with X slots into which any piece of content can fit up to X different content fragments... it just fits my model of how things work better than reaching in and rewriting the final template.

Actually ripping the HTML out of the old-code was surprisingly painful. Heck of a lot of twists and turns that needed to show up in the template. Still, it's a heck of a lot easier to follow as a simple template that's passed a dictionary telling it what sections to render rather than hundreds of extra lines of code doing if-tests on obscure fields of multiple records.

I'm debating whether to actually move the experiment into the code (I'm working on it with testing data at the moment). I should really finish the rewrite to use templates first, after all, a half-finished solution isn't going to convince anyone to use it.

That's not going to happen tonight, however, as I have to be up in less than 6 hours to get to the management meeting.

Comments

Comments are closed.

Pingbacks

Pingbacks are closed.