
daisuke at endeworks
May 11, 2009, 8:16 PM
Post #1 of 13
(1617 views)
Permalink
|
|
My experience porting to CataMoose
|
|
Hi, I've switched an application of mine to CataMoose. Thanks for the hard work, it's seems surprisingly stable for such a massive overhaul. I've observed a few glitches / gotchas, they seem like things that probably should be documented, but I'd like to share with the list before writing them up: 1. MyApp->config->{home} and Catalyst::Upgrading Catalyst::Upgrading suggests that the following is possible: package MyApp; use Moose; extends 'Catalyst'; __PACKAGE__->setup( ... ); This is fine, but things gets a bit hairy when you mix this with calls MyApp->config->{home} BEFORE setup(), for example: package MyApp; use Moose; extends 'Catalyst'; __PACKAGE__->config( 'View::TT' => { INCLUDE_PATH => __PACKAGE__->path_to('whatever') } ); __PACKAGE__->setup( .... ); path_to will return something like "/whatever" instead of "/path/to/MyApp/whatever", because home isn't set. to get around it, you would need to force setup_home() to be called, or say package MyApp; use Moose; use Catalyst; # so import() gets called extends 'Catalyst'; __PACKAGE__->config(...); __PACKAGE__->setup(...); 2. Hooking to methods that Plugins use via method modifiers breaks method dispatch I got bit by this while depending on Catalyst::Plugin::Unicode, and trying to hook a custom error handling mechanism at finalize(). I was doing this in MyApp.pm: before finalize => sub { my $c = shift; $c->handle_exception if @{ $c->error }; }; At that moment, Catalyst::Plugin::Unicode's finalize() stopped from being called. I fully expected MyApp->finalize() to trigger all the plugins' finalize(), then Catalyst::finalize(), but it only called MyApp::finalize() and Catalyst::finalize(). I never got exactly why this happens, but it seems to me like Moose's Method object interacts oddly with the method dispatch. My fix was to do override finalize => sub { my $c = shift; $c->handle_exception if @{ $c->error }; $c->next::method(@_); # doing super() didn't work here. }; regards, --d P.S. MST: yes, this has been blogged: http://mt.endeworks.jp/d-6/2009/05/moosification-catalyst-58.html _______________________________________________ List: Catalyst [at] lists Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst [at] lists/ Dev site: http://dev.catalyst.perl.org/
|