2010年8月7日土曜日

tipfy-ext-authのexampleのmulti-authを使ってみる。

一応multi-authの取得方法
http://code.google.com/p/tipfy-ext-auth/source/checkout
にあるように、
hg clone https://tipfy-ext-auth.googlecode.com/hg/ tipfy-ext-auth
とすると、exampleの中に入っている。

exampleなんだから、そのまま使えればいいのに、使えない...
どのように使うか考えてみる。

方針:/app/auth/の中に入れて、他のアプリからも、multi-authの機能を使えるようにしたい。

まず、
/app/auth/__init__.py
空のファイルを作っておく
/app/auth/urls.py
/app/auth/handlers.py
これをexampleからコピってくる。
exampleのconfig.pyから/config.pyに必要なとこをコピる。(どうせあとで設定が必要だが)

exampleのstaticを/staticへ
exampleのtemplatesをとりあえず/templates/auth/に全て移動。

/app/auth/urls.pyのruleのhandlerのところを
handler='apps.auth.handlers.HomeHandler'
の様に、適切なハンドラーをさすように全て変更。
(hello_worldの'/'とぶつかるので、'/hellosimple'とかにしておいた。)

/app/auth/handlers.pyのrender_response中を
return self.render_response('auth/home.html', section='home')
のようにして、/templates/auth/home.htmlなどを指し示すようにする。

この辺でhttp://localhost:8080/とかすると、エラーをはくので、
テンプレートもいじらねば。

将来的なことを考えて、
/templates/auth/layout.html

/templates/layout.html
に移動。
/templates/auth/login.html
などの中は
{% from 'auth/_form_macros.html' import form_field %}
と_form_macros.htmlのにはauthをつけておいた。

これで、一応エラーはでなくなったのだが、cssまわりが反映されてない。

/app.yaml

- url: /static
static_dir: static
を付け加えて、staticの中をちゃんと読めるようにした。(ただし、robot.txtとかの後に付け加えた。順番大事だったはず)

0 件のコメント:

コメントを投稿