Tweet <a href="#" onclick="Evernote.doClip({ styling:'full', providerName:'tf::blog', url:'http://blog.on-net.jp/tf/2011/02/catalyst-58.html', title:'Catalyst 5.8ã¸ã®ã¢ããã°ã¬ã¼ã - tf::blog', header: '
ãã®è¨äºã¯ï¼æ¥çµã½ããã¦ã¨ã¢2006å¹´9æå·ï¼é£è¼ãç°¡åå®è£ ã§å¦ã¶Webæè¡2006ãã®ç¬¬3åãCatalystââPerlåãWebã¢ããªã»ãã¬ã¼ã ã¯ã¼ã¯ãã®åé²ã§ããè¨äºã¯å·çæã®æ å ±ã«åºã¥ãã¦ããï¼ç¾å¨ã§ã¯ç°ãªãå ´åãããã¾ãã ããã«ã¡ã¯ï¼çµå浩ã§ããä»åã¯Perlã®Webã¢ããªã±ã¼ã·ã§ã³ã»ãã¬ã¼ã ã¯ã¼ã¯ãCatalystãã解説ãï¼ç°¡åãªã¡ã¢å¸³ããã°ã©ã ãä½ãã¾ãã Catalystï¼ã«ã¿ãªã¹ãï¼ã¯ï¼Perlã§ä½ãããWebã¢ããªã±ã¼ã·ã§ã³ã»ãã¬ã¼ã ã¯ã¼ã¯ã§ããCatalystã使ãã¨ï¼Webã¢ããªãç°¡åã«ä½æã»ãã¹ãã»é å¸ãããã¨ãã§ãã¾ããcatalystã¨ããåèªã®ããããã®æå³ã¯ï¼ã触åªããããã¯ãä¿é²ããããã®ãã§ããPerlã®ã¢ã¸ã¥ã¼ã«å士ã触åªã®ããã«ãã¾ãçµã³ã¤ãã¦ï¼Webã¢ããªä½æãä¿é²ãããã¨ããæå³ã®ååãªã®ã§ãããã Catalystã®ãªãã£ã·ã£ã«ãã¼ã¸ã¯
é¡å Catalyst::Manual::Intro - ã¯ããã¦ã®Catalyst 説æ ããã§ã¯ãªããã¾ãã©ããã£ã¦Catalystã使ãã®ããç°¡åã«ç´¹ä»ãã¾ããCatalystã®æåã«ã¤ãã¦èª¬æããç°¡åãªã¢ããªã±ã¼ã·ã§ã³ãææ©ãç«ã¡ä¸ããæ§åãã覧ã«å ¥ãã¾ãã Catalystã¨ã¯ï¼ Catalystã¨ã¯ã¨ã¬ã¬ã³ããªã¦ã§ãã»ã¢ããªã±ã¼ã·ã§ã³ã»ãã¬ã¼ã ã¯ã¼ã¯ã§ãããããã¦æè»ãªã®ã«ãããã¦ã·ã³ãã«ãRuby on RailsãSpring (Java)ãããã¦Catalystã®å ã¨ãªã£ãMaypoleã«ããä¼¼ã¦ãã¾ãã MVC Catalystã¯ã¢ãã«ã»ãã¥ã¼ã»ã³ã³ããã¼ã©(MVC)ã¨ãããã¶ã¤ã³ã»ãã¿ã¼ã³ãè¸è¥²ãã¦ãããããã³ã³ãã³ãããã¬ã¼ã³ãã¼ã·ã§ã³ãããã¼ç®¡çã¨ãã£ãåé¡ãç°¡åã«åãåãã¦ç¬ç«ããã¢ã¸ã¥ã¼ã«ã«ãããã¨ãã§ãã¾ãããããã¦åãåãããã¨ã§ä»ã®åé¡ãå¦
|tcsh| $ catalyst.pl myapp ||< ã§ãä½æããã myapp.pm ãã¾ãè¦ã¦ã¿ã¾ãã |perl| use Catalyst::Runtime 5.80; use parent qw/Catalyst/; use Catalyst qw/-Debug ConfigLoader Static::Simple/; PACKAGE->config( name => 'myapp' ); PACKAGE->setup(); ||< Catalyst::Runtime ã¯ã½ã¼ã¹ãèªãéã空å®è£ ã®ãããªã®ã§ãç¡è¦ãããããããªãã¨ãmyapp 㯠Catalyst ãç¶æ¿ãã¦ããã¨ã¨ãã«ãCatalyst ããã¼ããã¦ããã¨ãããã¨ã§ãè¦ã¦ããé çªã¨ãã¦ã¯ã +Catalyst::import +Catalyst::config +Catalyst::setup ã¨ãªãã
åºæ¥ã®æªã人ãCatalystã§ã¢ãã«åé¢ãåå¼·ããä»®ã¾ã¨ãã åã大ãããç´ãããããã¨ãå ¥ãä¹±ãã¦ã¾ãã ä½æ çã¢ãã«ãã³ã³ããã¼ã©ããåé¢ãããã³ã³ããã¼ã©ã«ãã¸ãã¯ãæ¸ããªã¨è¨ãã®ã catalystã§ã¯ã³ã³ããã¼ã©ã§$cã使ããããããã¯uriãªã¯ã¨ã¹ãããã£ãã¨ããã使ããªãã ã¤ã¾ãã³ã³ããã¼ã©ã«$cã使ãã¾ãã£ããã¸ãã¯ãæ¸ãã¦ãã¨ããã®é¨åããã¹ãããã®ã«ããã©ã¦ã¶ãããããã¹ãã§ããªããªã£ã¦ãã¾ãããã¹ãã®èªååãã§ããªããªããã ã¢ãã«åé¢ã®çç±ã¯ï¼ ãã¹ã¿ããªãã£ãä¸ãããã¨ï¼ãã¹ãã®èªååï¼ãã³ãã³ãã©ã¤ã³ãã¹ã¯ãªãããããã¢ãã«ã«æ¸ãããã¸ãã¯ã使ããããã Q.ã³ã³ããã¼ã©ã«æ¸ãããã¸ãã¯ã使ããããªãwgetãªãcurlãªãããã°ãããããï¼ A.ãã¹ãã§ã«ãã¼ã§ããã®ãå®è¡çµæã ãã«ãªãããã¸ãã¯ã®éç¨ããã§ãã¯ã§ããªããä»ã«ããã³ã³ããã¼ã©ã«æ¸ãããå¤é¨
CodeZineç·¨éé¨ã§ã¯ãç¾å ´ã§æ´»èºãããããããã¼ãã¹ã¿ã¼ã«ããããã®ã«ã³ãã¡ã¬ã³ã¹ãDevelopers Summitãããã¨ã³ã¸ãã¢ã®çããã¾ããã¼ã¹ãããããã®ã¤ãã³ããDevelopers Boostããªã©ããã¾ãã¾ãªã«ã³ãã¡ã¬ã³ã¹ãä¼ç»ã»éå¶ãã¦ãã¾ãã
Catalystã¯ãPerlã®Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã§ããåãPerlã®Webã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ãMaypoleã®å¾ç¶ã§ãRuby on RailsãStrutsã«ã¤ã³ã¹ãã¤ã¢ããã¦ä½ããããã®ã§ãã Maypoleã¯ãã¼ã¿ãã¼ã¹ã®CRUDï¼CreateãReadãUpdateãDeleteï¼ã«ç¦ç¹ãå½ã¦ããã¦ãã¾ããããCatalystã¯ãã£ã¨æ±ç¨çãªWebã¢ããªã±ã¼ã·ã§ã³ã®ããã«ä½ããã¾ãããããã¦ãRuby on RailsãStruts ã®è¯ãã¨ãåãããããæ´ç·´ãããWebã¢ããªã±ã¼ã·ã§ã³ãã¬ã¼ã ã¯ã¼ã¯ã«ãªã£ã¦ãã¾ãã Catalystã使ãã¨Webã¢ããªã±ã¼ã·ã§ã³ã«å¿ è¦ãªãã®ãã»ã¨ãã©å ¨ã¦æã«å ¥ããç°¡åãã¤ã¹ãã¼ãã«éçºã§ãã¾ãã Webãµã¼ãã¼ Catalystã¯ãCGIãmod_perlãmod_perl2ãlighttpdãFastCGIçã ãã
Catalystã§ä½¿ç¨ãã主è¦ãªã¢ã¯ã·ã§ã³å±æ§ã¨ç¹æ®ãªã¢ã¯ã·ã§ã³ã«ã¤ãã¦ãèªåãªãã«èª¿æ»ããçµæãã¾ã¨ãã¦ã¿ã¾ããã誤ãçããã°ããææãã ããï¼(_ _)ï¼ ã¢ã¯ã·ã§ã³å±æ§: Path ã³ã³ããã¼ã©ã®ããã±ã¼ã¸åï¼å¼æ°ã®æååã«ããURLãããã³ã°ãè¡ããã¡ã½ããåã¯ãããã³ã°ã«ä½¿ç¨ãããªããããã±ã¼ã¸åã¯å ¨ã¦å¤§æåãå°æåã«ç½®ãæãã¦ãããã³ã°ãè¡ãããã ããRootã³ã³ããã¼ã©ã¯ç¹æ®(以ä¸ã®ä¾ãè¦ã)ã ä¾01: http://localhost:3000/foo/bar/baz ã«ããã package MyApp::Controller::Foo::Bar; sub example_01 :Path('baz') { } å¼æ°ã®æååããªãå ´åã¯ãããã±ã¼ã¸åã®ã¿ã§ãããã³ã°ãè¡ãã ä¾02: http://localhost:3000/foo/bar ã«ããã package
ã¨ãããããCPANã§ã¬ã³ã¬ã³~/以ä¸ã«ã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ã ã¡ãªã¿ã«èªåã®~/.cpan/CPAN/MyConfig.pmã¯âã®ãããªæãã«~/local/以ä¸ã«ã¢ã¸ã¥ã¼ã«ãã¤ã³ã¹ãã¼ã«ããããã«è¨å®æ¸ã¿ã 'make_install_arg' => qq[SITEPREFIX=$ENV{HOME}/local PREFIX=$ENV{HOME}/local], 'makepl_arg' => qq[INSTALLDIRS=site LIB=$ENV{HOME}/local/lib/perl5 PREFIX=$ENV{HOME}/local], 'mbuildpl_arg' => qq[./Build --install_base $ENV{HOME}/local], ã»Task::Catalystã¨Catalyst::Develãã¨ããããã¤ã³ã¹ãã¼ã«ããã¨ã¯ã¨ã©ã¼ãåºããé©å®çª
Moosification: Catalyst 5.8ã«ç§»è¡ããéã«ã¡ãã£ã¨æ°ã¥ããäºã æåããMooseãã¼ã¹ã§ã¢ããªã±ã¼ã·ã§ã³ãä½ãã¨ããã®ã¯ãå®åã§ã¯ãªããªãé£ããã®ã¯ãããã¾ããä¸è¬è«ã¯ JPA #02ã§è©±ãã®ã§ããã¦ããã¾ããï¼åå ç³ãè¾¼ã¿ã¯ä»æ¥5/12ã¾ã§ã§ããï¼ï¼ã5.8 ããMooseåããCatalystã§ãã£ãåé¡ã»æ³¨æç¹ãã¡ãã£ã¨æ¸ãåºãã¦ã¿ã¾ãã 1. use Catalyst Catalyst::Upgradingãèªãã§ãã㨠package MyApp; use Moose; extends 'Catalyst'; __PACKAGE__->setup(qw/ ConfigLoader /); ã¨ãã表è¨ãè¦ãããããããã¯æ°ãã¤ããªãã¨é§ç®ã èªåãç´é¢ããåé¡ã¯ãpath_to()çã使ã£ãæã«èµ·ãã£ããpath_to() ã¯ç¾ã¢ããªã®ã«ã¼ããã£ã¬ã¯ããª
ã¯ããã« ååã§ã¯ãããã¼å¶å¾¡ã®ã¡ã½ããã使ç¨ãã¦ã¢ã¯ã·ã§ã³ããURLãé·ç§»ãããã¨ãªãå¥ã¢ã¯ã·ã§ã³ãå¼ã³åºãæ¹æ³ãããã¦ãªãã¤ã¬ã¯ããè¡ãæ¹æ³ãç´¹ä»ãã¾ãããããã§ã³ã³ããã¼ã©ã«é¢ãã主è¦ãªæ©è½ã«ã¤ãã¦ã®ç´¹ä»ãçµãã¦ãä»åããã¯ã¢ãã«ã«ç§»ã£ã¦ããããã¨æãã¾ãã ã¨ããã§ãCatalystã®5.7ãã5.8ã«ãã¼ã¸ã§ã³ã¢ãããããéã«ãå é¨ãå®è£ ããä»çµã¿ã¨ãã¦Mooseãæ¡ç¨ããã¾ãããMooseã¨ã¯Perl5ã«ãªãã¸ã§ã¯ãã·ã¹ãã ãå°å ¥ããããã®ã¢ã¸ã¥ã¼ã«ã§ãããããã¾ã§ã®blessã使ç¨ããPerlã®ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ãããç°¡åã«ãããå¤ãã®ãã¨ãå®ç¾ã§ãã¾ãã æ¬è¨äºã§ã¯ãç°¡åã«ã§ã¯ããã¾ããblessã¨Mooseãæ¯è¼ããPerlã®ãªãã¸ã§ã¯ãæåããã°ã©ãã³ã°ã«ã¤ãã¦èª¬æãããã®å¾ã§ã¢ãã«ã®æ¦è¦ã説æãã¦ããã¾ãã 対象èªè Perlã§ç°¡åãªã¹ã¯ãªãããä½æããã
Catalyst::Model::Adaptor - use a plain class as a Catalyst model è¦ã¯ã©ããªã¯ã©ã¹ã§ãCatalystã®ã¢ãã«ã«ãã¦ãããã¯ã©ã¹ã§ãã ãã¨ãã°ãããªã¯ã©ã¹ãä½ã£ã¦ lib/MyApp/DateTime.pm package MyApp::DateTime; use strict; use warnings; use base qw/DateTime/; use DateTime::Format::W3CDTF; sub now { my ($class, $args) = @_; $args->{time_zone} = 'local' unless $args->{time_zone}; return $class->SUPER::now(%$args); } sub parse { my ( $class, $str )
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}