Friday, July 15, 2005

A first taste of Spyce

Like many programmers, I have a tendency to accumulate unfinished side projects. One of these is a web application. Over the years it's gone from WebWare, to Woven, to CherryPy 1, to Quixote + Cheetah, to Nevow, and finally landed on CherryPy 2 + HTMLTemplate + SQLObject + SQLite.

Yes, continually rewriting the infrastructure code is probably the biggest reason it's a continually unfinished project, but on the other hand, it's become a fun sandbox for trying out different app servers, persistence layers, and template engines.

I've written a pretty large chunk of CherryPy-based plumbing, and I've liked it pretty well, but lately the HTMLTemplate-based code started getting a little too hairy. CherryTemplate didn't look particularly better, and I didn't like my previous experience with Cheetah, so I started looking around again. A few conversations with Jonathan Ellis convinced me to give Spyce a try.

Now, Spyce is more than a templating language--it implements both the app server and templating bits of the stack, and it doesn't look like CherryPy+Spyce would be a clean or efficient separation. Fortunately both frameworks make it easy to isolate non-presentation logic into pure, non-framework modules (which I have done), so much of it is probably salvageable.

So far, I like what I see. I didn't really grok tag libraries the first time I looked at it, but after getting my head around them by reading the source, they're pretty elegant. The templating language is nicely structured and expressive (which was the whole point of the exercise) and it fits my brain better than Cheetah's.

The one gripe I have with Spyce is its lack of URL abstraction. Given the multiple framework changes, I've become a total convert to the RESTful/"Cool URI" paradigm, which avoids exposing the site implementation structure in your URLs. CherryPy and Quixote do this very well, but Spyce is centered around the "one template file=one URL" paradigm.

If and when I move beyond Spyce's internal server and onto Apache, mod_rewrite will provide an inelegant but useable way to do it, but I'd rather my framework didn't force me to hack around it at that level.


Anonymous said...

try myghty... for me it feels better...

Anonymous said...

Just to ensure that your code remains unfinished check out django at

Anonymous said...

There's also TurboGears ( which uses CherryPy, SQLObject and the Kid templating language, plus some other bits and pieces in the plumbing.

Tim Lesher said...

Indeed... in fact, I've since moved (again!) to TurboGears for this project, although I haven't blogged about it yet.