2008/07/29


まずは素晴らしい出だしだと思う。
google-app-engine-oil - Google Code
Yet another web framework on Google App Engine.

Google App Engine Oil (GAEO) is an open-source web framework running on Google App Engine. It enables the web development on App Engine quick and less configurations.

http://code.google.com/p/google-app-engine-oil/
railsを狙ってるのかなぁ。
これから勉強を始めますが、まずは1分でアプリが作れてしまうという素晴らしい所をご紹介します。

Google App Engine Oil(GAEO)は、上記URLからダウンロード(もしくはsvn trunk取得)して下さい。
"gaeo/bin"にパスが通っている状態から説明します。

アプリケーションテンプレートの作成

gaeoコマンドで生成します。 # gaeo.py hello
The hello project has been created.
これだけでも動きます。試しに
# cd hello
# dev_appserver.py .
...
としてブラウザで"http://localhost:8080/"を開くと
gaeo1
いう画面が起動します。これだけでも実はモデルやディスパッチャやコントローラが生成され、テンプレートが用意されているのでいきなりコーディングが始められます。

コントローラの作成

gaeogenコマンドで生成します。 # gaeogen.py controlller say
Creating application/templates/say/ ...
Creating say.py
これでsayコントローラが生成されます。中身は from gaeo.controller import BaseController

class SayController(BaseController):
    pass
こんな感じ。あとはこれを少し修正して #!-*- coding:utf-8 -*-
from gaeo.controller import BaseController

class SayController(BaseController):
  def hello(self):
    self.render(text = 'こんにちわ世界')
とし、"http://localhost:8080/say/hello"にアクセスすると"こんにちわ世界"と表示されます。また"templates/say/"に"hello.html"を以下の様に作成し こんにちわ {{ word }}
先ほどのsay.pyを以下の様に書き換えます。
#!-*- coding:utf-8 -*-
from gaeo.controller import BaseController

class SayController(BaseController):
  def hello(self):
    self.render(
        template = 'hello',
        values = { 'word' : '世界' }
    )
これでテンプレートを使ったページが出来上がります。

目新しい点

私はここに注目しました。
これまでjsonやxmlをGAEから出力する際には、Content-Typeの設定が必要であったりしましたがGAEOならば上記textやtemplateと同じ様に
#!-*- coding:utf-8 -*-
from gaeo.controller import BaseController

class SayController(BaseController):
  def hello(self):
    self.render(
        xml = '<xml />',
    )
としたり #!-*- coding:utf-8 -*-
from gaeo.controller import BaseController

class SayController(BaseController):
  def hello(self):
    self.render(
        json = '{ word : "Hello, World!" }',
    )
とするだけで、正しいContent-Typeを返してくれるようになります。

期待したい所

リクエストパラメータself.paramsでパラメータをdictとして受け取れたり、self.sessionで簡単にセッションが扱えたりと開発者にとって扱いやすいフレームワークになっていると思われます。
ただ現状gaeogenコマンドではcontrollerしか生成出来ていません。おそらく今後modelの生成も出来る様になるかと思いますので今後に期待したいです。出来ればrails相当になってくれれば良いですね。

まだちゃんと勉強してないのでこれから色々調べていきます。
Posted at by



2008/07/28


不具合報告を頂きまた。自分でも動かなくなってたのに気付いてませんでした。
Big Sky :: XSLとjQuery/HTMLだけで作る、amazon最速検索
http://mattn.kaoriya.net/software/lang/javascript/20080605165643.htm
どうやら、jQueryがcacheを無効にする時に使用する特殊パラメータ"_"がAmazonで蹴られる様になったのが原因です。
結構ハマった(30分)割には、直し方は簡単。
$.ajaxSettings.cache = true; まぁ、Amazon検索にはリアルタイムなキャッシュ無効は必要なさそうなので、これで良しとします。
一応、直ったのでこの記事にも実行例置いときます。コードは↑のリンク先を参照下さい。

続きを読む...

Posted at by



2008/07/25


これはいいね。
Google App Engine Blog: Some small updates!
We're happy to announce we've released some small updates to Google App Engine. Among the more significant changes:
  • More apps: Want to create more than 3 applications with your App Engine account? Now you can now create up to 10!
  • Time windows for Dashboard graphs: Zoom in on the data in your dashboard to get a more accurate picture of whats going on. You can zoom in to see graphs for the last 24, 12, and 6 hour periods.
  • Logs export: You can now use appcfg.py to download your application's logs in plaintext format. Use appcfg.py --help for more information on how to download your logs.
  • Send email as logged in user: If you're using the users API, you can now send email from the email address of the currently-logged-in user.
最新版のダウンロードはこちらから。
作れるアプリ数が10個に増え
あと8個
ダッシュボードのデータ時系列が拡大できる様になって
6時間単位で拡大可能
appcfg.pyでログがエクスポート出来る様になって # appcfg.py request_logs <directory> <output_file> 現在ログイン中のユーザのメールアドレスが得られる様になったらしい。

やるね。Google App Engine。
Posted at by