CodeZine編集部では、現場で活躍するデベロッパーをスターにするためのカンファレンス「Developers Summit」や、エンジニアの生きざまをブーストするためのイベント「Developers Boost」など、さまざまなカンファレンスを企画・運営しています。
モダンPerlの世界へようこそ 第7回Catalyst::DispatchType::Chained:チェーンドアクションはむずかしい? 5.7系列の目玉だったチェーンドアクション 3年前に登場したCatalyst 5.7系列で導入された機能のひとつに、チェーンドアクションと呼ばれるものがあります。これは慣れると非常に便利な機能なのですが、それまでのURLとクラスの対応を根底から覆してしまう大転換だったわりにドキュメントが不足していたため、活用の仕方がわからないという声もありました。 今回はCatalyst 5.8系列で導入された新しいツールを使いながら、このチェーンドアクションの使い方を紹介していきます。スペースの都合でCatalystの基本はある程度理解しているものとして話を進めますので、わからないことがあったらCatalyst本体のドキュメントやCatalyst::Manualなどを
3年前の大混乱 モダンPerl界を代表するウェブアプリケーションフレームワークといわれるCatalystが2006年半ばに5.6系統から5.7系統に移行したとき、創始者のゼバスティアン・リーデル氏を追い出す形で集団管理体制に移行した開発チームが最初にしたことは、プロジェクト開始当初から使われてきたCatalystという名のディストリビューションはそのままに、Catalyst-Runtimeという新しいディストリビューションをつくることでした。 このようなディストリビューション名の変更は、CPANクライアントを使っている分には(内部でモジュール名からディストリビューション名への変換が行われるので)問題にならないのですが、外部のパッケージ管理者たちには少なからぬ負担をかけました。なにしろ突然100を越す関連パッケージの依存が変更になるのです。基本的にはメタ情報だけ書き換えれば済む話とはいえ、従
以前、Catalystでマルチバイトを取り扱うときのまとめという記事を書いたのですが、情報が少し古いので、最近僕がやっている方法を紹介します。 この記事では Catalyst 5.7015 Catalyst::View::TT 0.27 Catalyst::Plugin::ConfigLoader 0.22 Catalyst::Plugin::FillInForm 0.10 Catalyst::Plugin::Static::Simple 0.20 Catalyst::Plugin::Unicode 0.8 の環境で紹介しています。 また、基本的にDBICに関しては以前の記事の通りDBIx::Class::UTF8Columnsを使うという感じです。 まず、こんな感じのアプリケーションを用意します。 MyApp package MyApp; use strict; use warnings
これもよく使うくせによく忘れるので備忘。 まずはCatalystのControllerでData::Page::Navigationをuseして MyApp::Controller::User package MyApp::Controller::User use strict; use warnings; use parent 'Catalyst::Controller'; use Data::Page::Navigation; sub index : Path : Args(0) { my ( $self, $c ) = @_; my $page = $c->req->param('page') || 1; my $rows = $c->req->param('rows') || 10; my $users = $c->model('DBIC::Users')->search( {},
最近はもっぱらこんな構成 MyApp/ |-- Changes |-- Makefile.PL |-- README |-- conf - 設定ファイルはまとめてここへ | `-- myapp.conf |-- docs - ドキュメントとかSQLとか |-- lib | |-- MyApp | | |-- Base - Base::Controllerとか基底クラス | | |-- Component - ビジネスロジッククラス | | |-- Controller | | |-- Model | | |-- Plugin - オレオレプラグイン | | |-- Schema - DBICのスキーマ | | `-- View | `-- MyApp.pm |-- root | |-- db - SQLiteを使うときはこの辺 | |-- static | | |-- scripts -
新しく作った開発プロセスの問題点が見えたわけだから、それはそれとして改善すればいいのに。プロジェクトに併せてテーラリングされてないのとか。そういうことを自発的にやれる人たちが必要だというのもわかるけど ■ [catalyst][chaostr] Catalyst::Controller::Resouce を使って、Chained アクション書くのを楽する 追記(2009-05-20T16:46:42+09:00) 現在は Catalyst 5.8 系に対応した C:C::Resources がリリースされており、この方法は使用できません。 Catalyst 5.7 系 + C:C::Resources 0.4 系であれば使用可能です。 追記(2009-06-15T01:02:03+09:00) perl-mongers.org に Cat 5.8 系の話を書きました。 Catalyst::
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
例外的に、ConfigLoaderとStatic::Simple、あとAuthenticationやSession、Cacheあたりは使ってもいいけれど、それ以外は基本的に使っちゃいけない。 #や、Authなんかはまだ新しいAPIに追随してないのがあるから、これもやめとけって言った方が無難かな。つくった本人使ってないし。 これだけ言ってもプラグインを使うんだったら、どこがどう動かなくなろうと文句は言わないでね。警告を読まなかったとは言わせないよ。 それから、そこで「プラグインを使ったっていいんでないの?」とか言ってる人。そこまで言うんだったら、IRCとかメーリングリストとかで空気を読めなかった初心者が泣き言を言ったときには、あなたたちが対応してちょ。 これからプラグインをつくろうとしている人もそう。みんな過去のくさったプラグインのせいでとても迷惑している。これ以上頭痛の種を増やさんでちょー
自分の為のメモですよ。 準備 まずはCatalystプロジェクトを作ります $ mkdir -p /path/to/dir $ cd /path/to/dir $ catalyst.pl AuthSample ユーザー用のDBICスキーマを定義します。 $ module-starter --module AuthSample::Schema $ cd AuthSample-Schemaでこのディレクトリにて、 CREATE TABLE user ( user_seq INTEGER PRIMARY KEY, user_id TEXT UNIQUE, password TEXT, created_on DATETIME, updated_on DATETIME ); こんなスキーマを定義して、schema.sqlとして保存して、 $ sqlite3 -init schema.sql auth
いままでずっと JSON::Syck を使い続けていたのだけど、いまの JSON::Syck には /y|Y |n|N |yes|Yes|YES |no|No|NO |true|True|TRUE |false|False|FALSE |on|On|ON |off|Off|OFF |null|Null|NULL |~ /x の正規表現にマッチする値はシングルクオートでくくられてしまうという仕様があり、これはJSONの仕様に反するのでパーサーによっては正しく処理できないものがある。 これがFlashから使うJSON APIでもろにはまって、adobe の corelib に入っている JSON のパーサーはこれをパースできない。(rubyのyamlパーサーでもエラーになるようだ) cho45さんがこれを直すパッチを書いてくれたのだけど、いい機会なので JSON::XS を試してみた。JSON
[Catalyst] cpan[1]> install Catalyst::Pligin::Unicode cpan[2]> install Catalyst::View::TT::ForceUTF8 vim lib/MyApp.pm use Catalyst qw/ Unicode ←追加 /; vim lib/MyApp/View/TT.pm use base 'Catalyst::View::TT'; ↓変更 use base 'Catalyst::View::TT::ForceUTF8'; __PACKAGE__->config({ DEFAULT_ENCODING => 'utf-8', ←追加 }); 内部はフラグ付、外部出力時はフラグ無しのUTF8となる。
Soozy Conference #4あたりからtokuhiromさんが声を大にして言っているCatalystのNEXT気持ち悪い説。 酒の席でこの話になるたびに奥の座敷から大声で呼び出されるCatalystのNEXT気持ち悪い説。 気を抜いてDBICを褒めるとClass::C3も同じじゃねーかとDisられるCatalystのNEXT気持ち悪い説。 僕も激しく同意。なのでちょっとまとめておく。 NEXTを使う場合、こんな感じかと。 use strict; use warnings; use NEXT; package PluginA; sub foo { print "A"; shift->NEXT::foo; } package PluginB; sub foo { print "B"; shift->NEXT::foo; } package Object; use base qw/
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
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 )
はてなグループの終了日を2020年1月31日(金)に決定しました 以下のエントリの通り、今年末を目処にはてなグループを終了予定である旨をお知らせしておりました。 2019年末を目処に、はてなグループの提供を終了する予定です - はてなグループ日記 このたび、正式に終了日を決定いたしましたので、以下の通りご確認ください。 終了日: 2020年1月31日(金) エクスポート希望申請期限:2020年1月31日(金) 終了日以降は、はてなグループの閲覧および投稿は行えません。日記のエクスポートが必要な方は以下の記事にしたがって手続きをしてください。 はてなグループに投稿された日記データのエクスポートについて - はてなグループ日記 ご利用のみなさまにはご迷惑をおかけいたしますが、どうぞよろしくお願いいたします。 2020-06-25 追記 はてなグループ日記のエクスポートデータは2020年2月28
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く