<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Peter's Blog - Nodes for dgango</title>
    <link>http://www.petersblog.org/</link>
    <description>Nodes containing the tag dgango</description>
    <item>
      <title>TurboGears</title>
      <link>http://www.petersblog.org/node/view/1070</link>
      <description>&lt;p&gt;
I've been giving &lt;a href="http://www.turbogears.org/"&gt;TurboGears&lt;/a&gt; a try as a means of reimplementing this blog in &lt;a href="/tag/python"&gt;python&lt;/a&gt;. I have been trying &lt;a href="/tag/django"&gt;django&lt;/a&gt; but I felt the need to try something else, mainly prompted by frustrations with the database api. 
&lt;/p&gt;
&lt;p&gt;
TurboGears is similar in the tools that it provides for web application development. It is essentially an amalgum of a number of existing python projects: 
&lt;/p&gt;
&lt;dl&gt;&lt;dt&gt;kid&lt;/dt&gt;&lt;dd&gt;
a templating system based on XML. 
&lt;/dd&gt;
&lt;dt&gt;cherrypy&lt;/dt&gt;&lt;dd&gt;
web application framework, essentially maps urls to python method calls 
&lt;/dd&gt;
&lt;dt&gt;SQLObject&lt;/dt&gt;&lt;dd&gt;
an SQL database wrapper 
&lt;/dd&gt;
&lt;dt&gt;Mochikit&lt;/dt&gt;&lt;dd&gt;
a javascript library which I have tried &lt;a href="/tag/mochikit"&gt;before&lt;/a&gt; 
&lt;/dl&gt;&lt;/dd&gt;

&lt;p&gt;
Turbogears itself provides 'glue' to put these together. It has tools for creating project files, setting up and using the database etc. The TurboGears administration script creates a boilerplate application that can be running in no time. It all feels very similar to django, the main thing missing I can see is the administration screens but they are working on something called 'catwalk' which I think will do this. At the end of the day there are many database front ends that can provide administration (phpmyadmin, webmin mysql module etc) which are not so end-user friendly but good enough for me. 
&lt;/p&gt;
&lt;p&gt;
The librarys that turbogears has chosen appear to be very good in their own rigght. Their designs are clean and they are well documented. Each has greater depth than the django equivalents. 
&lt;/p&gt;
&lt;p&gt;
Kid looks powerful: it is an intersting mix of xml and python: your kid scripts can be used like python modules: they compile to .pyc files and so are presumably only parsed once. You can define xml snippets of boilerplate code, such as an html list, and call it like a function from elsewhere in your template. As it is XML based, if your template is not XML compliant the XML parser (expat at the lowest level) slaps your wrist. An interesting side effect of the pythonic nature of it is that if a problem appears in the python embedded in your template, Wing IDE's debugger will stop on that line. Useful! Kid does not support inheritance like django's template system, it effectively gives you macro templates that could be very powerful. The syntax is clearer than django, you can use python code inline )like &lt;a href="/tag/cheetah"&gt;cheetah&lt;/a&gt;) and the template substitution allows you to use the same substitution twice (if, for example, you want to use the same title string in two places, header and page title): a pedantic limitation in django. Looking through the documentation, Kid shows great attention to xhtml compliance and generation of conformant XHTML. This is not the greatest concern to me, I don't lose sleep over whether my XHTML is standards compliant, I am more worried about whether browsers will display it properly, but it is nice to know that someone somewhere has thought about all this for me. 
&lt;/p&gt;
&lt;p&gt;
SQLObject looks very clean and the objects can be introspected nicely. You work with the classes you define directly and not with meta classes that appear from nowhere. SQLObject has also introduced me to &lt;a href="http://www.sqlite.org/"&gt;SQLite&lt;/a&gt; a really nice, simple SQL database library. This looks very solid, certainly good enough for development without the hastle of getting &lt;a href="/tag/mysql"&gt;mysql&lt;/a&gt; running. It would probably be good enough for production use for me, if I can get it to run SQL dumps for backup (which I prefer to backing up binarys). Certainly I will be using it in the places where I can't be bothered to set up mysql (user's, permissions, passwords, yawn). 
&lt;/p&gt;
&lt;p&gt;
CherryPy: TurboGears creates enough boilerplate code that I haven't needed to look at the documents for this yet. It maps urls to method calls simply enough but one thing I like about django is the regular expression based url mapping which is totally flexible but there is nothing to stop me adding such a mapping layer. 
&lt;/p&gt;
&lt;p&gt;
I've ported the basics of my blog (the theme I use in drupal, lists of posts etc) to TurboGears. I had to study the Kid documentation to get the TurboGears generated code to use the head from the master.kid file so I could put my css import in one fixed place. By default the head here is ignored. The solution to this conundrum is to modify master.kid like this: 
&lt;/p&gt;
&lt;pre class="lazy"&gt;&lt;span class="MetaTag"&gt;&lt;span class="MetaTag"&gt;&amp;lt;&lt;/span&gt;&lt;span class="MetaTag"&gt;head&lt;/span&gt; &lt;span class="MetaTag"&gt;py:match&lt;/span&gt;=&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;item.tag=='&lt;span class="String"&gt;{http://www.w3.org/1999/xhtml}&lt;/span&gt;head'&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;&lt;span class="MetaTag"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class="MetaTag"&gt;&lt;span class="MetaTag"&gt;&amp;lt;&lt;/span&gt;&lt;span class="MetaTag"&gt;meta&lt;/span&gt; &lt;span class="MetaTag"&gt;content&lt;/span&gt;=&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;text/html; charset=UTF-8&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="MetaTag"&gt;http-equiv&lt;/span&gt;=&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;content-type&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="MetaTag"&gt;py:replace&lt;/span&gt;=&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;''&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt;/&lt;span class="MetaTag"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class="MetaTag"&gt;&lt;span class="MetaTag"&gt;&amp;lt;&lt;/span&gt;&lt;span class="MetaTag"&gt;title&lt;/span&gt;&lt;span class="MetaTag"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;Peter's Better Blog | ${strPageTitle}&lt;span class="MetaTag"&gt;&lt;span class="MetaTag"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="MetaTag"&gt;title&lt;/span&gt;&lt;span class="MetaTag"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span class="MetaTag"&gt;&lt;span class="MetaTag"&gt;&amp;lt;&lt;/span&gt;&lt;span class="MetaTag"&gt;link&lt;/span&gt; &lt;span class="MetaTag"&gt;rel&lt;/span&gt;=&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;stylesheet&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; &lt;span class="MetaTag"&gt;href&lt;/span&gt;=&lt;span class="String"&gt;&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;/static/css/style.css&lt;span class="String"&gt;&amp;quot;&lt;/span&gt;&lt;/span&gt; /&lt;span class="MetaTag"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class="MetaTag"&gt;&lt;span class="MetaTag"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="MetaTag"&gt;head&lt;/span&gt;&lt;span class="MetaTag"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/pre&gt;
&lt;p&gt;
i.e. turn it into a match template. I had the django inheritance thing in my head (not a million miles away from the drupal phptemplate engine) and I had to read the kid documentation to realise it simply works by sequentially replacing blocks of XML, in this case any later head block is replaced by the block above. 
&lt;/p&gt;&lt;p&gt;Related Posts: &lt;a href="/tag/cheetah"&gt;cheetah&lt;/a&gt; &lt;a href="/tag/dgango"&gt;dgango&lt;/a&gt; &lt;a href="/tag/python"&gt;python&lt;/a&gt; &lt;a href="/tag/turbogears"&gt;turbogears&lt;/a&gt; &lt;a href="/tag/wingide"&gt;wingide&lt;/a&gt;&lt;/p&gt;</description>
      <guid>http://www.petersblog.org/node/view/1070</guid>
      <category domain="http://www.technorati.com/tag">cheetah</category>
      <category domain="http://www.technorati.com/tag">dgango</category>
      <category domain="http://www.technorati.com/tag">python</category>
      <category domain="http://www.technorati.com/tag">turbogears</category>
      <category domain="http://www.technorati.com/tag">wingide</category>
    </item>
  </channel>
</rss>
