GAEOにScaffoldのジェネレータが付いた。どれだけ速くアプリケーションを作れるか。
アプリケーションを作る
# gaeo.py gaeotter
The "gaeotter" project has been created.
# cd gaeotter
Scaffoldを作る
# gaeogen.py scaffold posts index new show user:StringProperty(required=True) comment:StringProperty(required=True)
Creating Model posts ...
Creating .../gaeotter/application/model/posts.py ...
Creating .../gaeotter/application/templates/posts ...
Creating .../gaeotter/application/templates/posts/index.html ...
Creating .../gaeotter/application/templates/posts/new.html ...
Creating .../gaeotter/application/templates/posts/show.html ...
Creating Controller posts ...
Creating .../gaeotter/application/controller/posts.py ...
テンプレートを少しだけ編集する
# vim application/templates/posts/index.html
# cat !$
<h1>PostsController#index</h1>
<a href="/posts/new">New</a>
<ul>
{% for rec in result %}
<li><a href="/posts/show?key={{ rec.key }}">{{ rec.comment|escape }}</a> by {{ rec.user|escape }}</li>
{% endfor %}
</ul>
# vim application/templates/posts/show.html
# cat !$
<h1>PostsController#show</h1>
<p>user: {{ user|escape }}</p>
<p>comment: {{ comment|escape }}</p>
起動する
# dev_appserver.py gaeotter
INFO 2008-12-16 05:03:03,546 appcfg.py] Server: appengine.google.com
INFO 2008-12-16 05:03:03,937 appcfg.py] Checking for updates to the SDK.
INFO 2008-12-16 05:03:04,437 appcfg.py] The SDK is up to date.
INFO 2008-12-16 05:03:05,062 dev_appserver_main.py] Running application gaeo
tter on port 8080: http://localhost:8080
# firefox http://localhost:8080/posts/
結論
Google App Engine Oilすばらしい。