Web Services Infrastructure: Kid Templating

Ryan Tomayko put up an article describing the genesis of Kid as an answer for generating responses for web services. Right now, TurboGears produces HTML and JSON as part of the out-of-the-box experience. I definitely expect that we’re going to see the ability to specify a Kid template for XML output.

I think that toward the end of my time in Javaland, an increasing number of the blogs I read seemed to be doubting WS-*. The problem with a specs like WS-* is that when people just sit down to crank out a “standard API”, they’re going to try to take into account every possible need. The best APIs I’ve used, though, are the ones that focus on making the common case as easy as possible, and leaving the door open enough to deal with uncommon issues. These APIs are generally made better because people actually use them.

There’s a reason that people still use XML-RPC, despite the existence of SOAP. It’s simple and it gets the job done for a fair number of scenarios…

3 thoughts on “Web Services Infrastructure: Kid Templating”

  1. I was playing with this idea and thinking about how to overload the turbogears.expose decorator to incluide something like:
    turbogears.expose(… html=’html.kid’ xml=’something.xml’ csv=’another’)

    then I could have a hook to expose the data in any page in any format. I’m not sure how to resolve the mapping with pretty urls in cherrypy though.

    Something like
    site.com/people/aaron -> html
    site.com/people/aaron.xml -> xml
    site.com/people/aaron -> html
    site.com/people/aaron?frmt=xml -> xml

  2. I think Kid templates work very nicely for this… Here’s a Rails builder:

    xml.response(:code => @code) do
    xml.items do
    @items.each do |item|
    xml.item do
    xml.unit_price(item.product.list_price, :currency => “usd”)


    It’s basically just the same thing inverted. Rather than a little XML in your Ruby, you get a little Python in your XML 🙂

Comments are closed.