差分表示
- 最後の更新で追加された行はこのように表示します。
- 最後の更新で削除された行は
このように表示します。
*jifty
遊びで[[Jifty>http://jifty.org/view/HomePage]]をつかってみた。[[Ruby on Rails>http://www.rubyonrails.org]]のPerl版。
buildは[[subversion repositryをcheckout(*1)>https://svn.jifty.org/svn/jifty.org/jifty]]したあと、trunk配下で
-1. perl Makefile.PL
-2. make
--''注意事項''
--2.1 依存するCPAN moduleを大量にinstallする。ものすごく長いtestとかがあるので、諦めて放置するのが吉。またmoduleをinstallするか聞かれるので、諦めて画面は定期的に眺めるのがいい
--2.2 make終了後は /usr/bin/jiftyコマンドがあるので、実行してみる。まだ入っていない依存するCPAN moduleがあってjiftyが起動できない場合は、地道に必要なCPAN moduleをinstallする
--2.3 jiftyが無事に動くようになったら、こんな感じになる。--helpオプションは爽やかに未実装くさいので注意w
--2.3 jiftyが無事に動くようになったら、こんな感じになる。
---(
% jifty
Can't guess application root from current path (/home/mage) or bin path (/usr/bin)
Command not recognized, try /usr/bin/jifty --help.
action - add an action class to your jifty application
adopt - localize a stock jifty component
app - create the skeleton of a jifty application
console - a console for your jifty application
deps - looks for module dependencies and attempts to install them from cpan
env - access the jifty environment
fastcgi - a fastcgi server for your jifty application
help - show help
modperl2 - a modperl2 handler for your jifty app.
model - add a model class to your jifty application
plugin - create the skeleton of a jifty plugin
po - extract translatable strings from your application
repl - a repl for your jifty application
schema - create sql to update or create your jifty app's tables
script - add a new jifty script to your jifty application
server - a standalone webserver for your jifty application
---)
-3. テストアプリケーションは以下手順で作成できる
--3.1 jifty app --name [appname]
---appnameのdirecotryをcwd配下に作成して、WebAppに必要なフォルダ・ファイルを作成する
---ひな形フォルダ構成は以下の通り。http://localhost:8888として WebAppがみえる設定になっている。
---(
% find MyApp/ -type f
MyApp/bin/jifty WebApp起動用のjifty script。基本、このscriptを使う。
MyApp/var/jifty-server.pid
MyApp/Makefile.PL
MyApp/etc/config.yml 構成ファイル
MyApp/myapp
---)
--3.2 [appname]/bin\jifty schema --setup
---これが何するのかよくわからん
--3.3 [appname]/bin\jifty server
---server subcommandで起動できる。このsubcommandでforkしたprocessがHTTP serverになる。listen portは引数で指定可能。
-(*1) download pageに載っているリンクはhttpだが、svnでcheck outするときは httpsじゃないとダメぽい。載せたリンクは爽やかにhttpsにしてある
*jifty knowhow memo
** etc/config.yml
.ymlは[[YAML>http://ja.wikipedia.org/wiki/YAML]]に準じたTextのデータ形式。notationに沿っていないとparse errorで YAML::Syckモジュールがエラーをはく。
参考文献
-http://jp.rubyist.net/magazine/?0009-YAML
--プログラマーのための YAML 入門 (初級編)
** Jifty/Plugin/Login
これをinstallする上で依存関係のあるpkgを入れる必要があるが、爽やかにbuildが通らない。修正は以下の通り。
*** LWPx::ParanoidAgent-1.03
--testがおかしい。blogに書いてる人がいた
--http://n.koshikawa.net/archives/2008/07/lwpxparanoidagent.html
---(
37 # hostnames pointing to internal IPs
38 $res = $ua->get("http://localhost-fortest.danga.com/");
39 ok(! $res->is_success && $res->status_line =~ /Suspicious DNS results/);
---)
--テストが通るための条件は以下の通り。
--- $res->is_success == 0、つまりGETは200以外
--- $res->status_line =~ /Suspicious DNS results/が真、つまりGETを出す前に HTTP::Responseがこのエラー文で戻る
--これはParanoidAgentで実装しているresolverの箇所のテストの模様。この文面のエラーmsgはHTTP::Responseが使う HTTP::Statusがもつ msgには存在しなく、以下の箇所にのみ存在する
---(
lib/LWPx/ParanoidAgent.pm
46 sub _resolve {
47 my ($self, $host, $request, $timeout, $depth) = @_;
48 my $res = $self->resolver;
49 $depth ||= 0;
50
51 die "CNAME recursion depth limit exceeded.\n" if $depth > 10;
52 die "Suspicious results from DNS lookup" if $self->_bad_host($host);
53
54 # return the IP address if it looks like one and wasn't marked bad
55 return ($host) if $host =~ /^\d+\.\d+\.\d+\.\d+$/;
56
57 my $sock = $res->bgsend($host)
58 or die "No sock from bgsend";
59
60 my $rin = '';
61 vec($rin, fileno($sock), 1) = 1;
62 my $nf = select($rin, undef, undef, $self->_time_remain($request));
63 die "DNS lookup timeout" unless $nf;
64
65 my $packet = $res->bgread($sock)
66 or die "DNS bgread failure";
67 $sock = undef;
68
69 my @addr;
70 my $cname;
71 foreach my $rr ($packet->answer) {
72 if ($rr->type eq "A") {
73 die "Suspicious DNS results from A record\n" if $self->_bad_host
---)
--なので、このテストを通すために DNSからの戻りを細工しておく必要がある模様。結局の対応はこのテストは通すことにした。(blogの人はテストの総数を減らした)
---(
37 # hostnames pointing to internal IPs
38 #$res = $ua->get("http://localhost-fortest.danga.com/");
39 #ok(! $res->is_success && $res->status_line =~ /Suspicious DNS results/);
40 ok(1);
---)
*** Devel::Gladiator
Changelog にはこんな感じに書いてある。かなり怪しいって言うか、こう言うのは爽やかに排除してほしい orz
---(
328 INSTALL
329 =======
356 * Add Devel::Gladiator to Makefile.PL, other little fixes in here - sartak
462 PLUGIN
463 ======
467 * A first pass attempt at a Devel::Gladiator plugin for Jifty. Doesn't seem
468 to work very well - jesse
3101 Jifty 0.70116
3102
3241 Internals
3244 * Removed support for Devel::Gladiator. It was very, very beta and
3245 caused server processes to end up as zombies -jesse
---)
Devel::Gladiatorのありかは http://code.sixapart.com/svn/Devel-Gladiator である。
coしたものをinstallすることはできたので、とりあえず入れてみた。 orz
*** WWW::Facebook::API
--0.4.13のdiffで以下のdiffがあるが、このfixがまずいらしい
---(
@@ -353,8 +355,7 @@ sub _add_url_params {
sub _parser {
my $parser = JSON::Any->new;
- # JSON::Any needs to get fixed
- $parser->handler->allow_nonref() if $parser->handlerType eq 'JSON::XS';
+ $parser->handler->allow_nonref;
return $parser;
}
---)
--爽やかにpatch前に戻すと testは通せる。
Last-modified: 2008-09-18 13:58:34