White scenery @showyou, hatena

If you have any comments, you may also send twitter @shsub or @showyou.

makoテンプレートを使う。

使い易そう。軽くSQL検索→結果出力とかに使うのはいいかも。
main.mako

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
        <head>
                <title>Sample HTML</title>
        </head>
        <body>
                <h1>Sample</h1>
                <hr />
                <div class="content">
                        % for m in messages:
                                <div class ="message">
                                        <span class="message_header">${m["name"] | h}</span>
                                        <span class="message_body">${m["content"] | h}</span>
                                </div>
                        % endfor
                </div>
        </body>
</html>

python

>>> from mako.template import Template
>>> mytemplate = Template(filename="main.mako")
>>> ms = { "messages": [ {"name":"hoge","content":"foo"}]}
>>> ms
{'messages': [{'content': 'foo', 'name': 'hoge'}]}
>>> print mytemplate.render(**ms)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
        <head>
                <title>Sample HTML</title>
        </head>
        <body>
                <h1>Sample</h1>
                <hr />
                <div class="content">
                                <div class ="message">
                                        <span class="message_header">hoge</span>
                                        <span class="message_body">foo</span>
                                </div>
                </div>
        </body>
</html>

これとsqlalchemy組み合わせれば楽にDB表示システムできそうですね。・・もはやそれpylonsじゃないかって気もするけど。