[Catalyst] overriding Catalyst::Model::CDBI::new()

Luke Meyer luke at daeron.com
Thu Sep 1 05:30:45 CEST 2005


I'd like to meddle with some loaded DB classes after they're loaded.  So 
I figured I'd just override the new() method and add my meddling at the 
end.  However, it seems Catalyst::Model::CDBI behaves badly with 
overriding.  I don't quite see why yet.  Try this out:

$ catalyst.pl App
$ cd App
$ script/app_create.pl model DB CDBI
$ cat >> lib/App/M/DB.pm
sub new { shift()->SUPER::new(@_) }  #should just propagate up
1;
<EOF>
$ vi lib/App/M/DB.pm  #and add database connection info
$ script/app_server.pl
[...]
[Wed Aug 31 23:24:41 2005] [catalyst] [debug] Loaded tables "Rating 
Session User UserLog sessions"
Use of uninitialized value in pattern match (m//) at 
/Library/Perl/5.8.6/Class/DBI/Loader.pm line 75.
Use of uninitialized value in string eq at 
/Library/Perl/5.8.6/Class/DBI/Loader.pm line 76.
Use of uninitialized value in concatenation (.) or string at 
/Library/Perl/5.8.6/Class/DBI/Loader.pm line 77.
[Wed Aug 31 23:24:41 2005] [catalyst] [debug] Couldn't load tables 
"Couldn't require loader class "Class::DBI::Loader::", "Can't locate 
Class/DBI/Loader/.pm in @INC (@INC contains: 
/Users/luke/code/Catalyst/App/script/../lib 
/System/Library/Perl/5.8.6/darwin-thread-multi-2level 
/System/Library/Perl/5.8.6 
/Library/Perl/5.8.6/darwin-thread-multi-2level /Library/Perl/5.8.6 
/Library/Perl /Network/Library/Perl/5.8.6/darwin-thread-multi-2level 
/Network/Library/Perl/5.8.6 /Network/Library/Perl 
/System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level 
/System/Library/Perl/Extras/5.8.6 /Library/Perl/5.8.1 .) at (eval 51) 
line 2.
BEGIN failed--compilation aborted at (eval 51) line 2.
" at /Library/Perl/5.8.6/Class/DBI/Loader.pm line 79.
"
Couldn't instantiate component "App::M::DB::SUPER", "Can't call method 
"classes" on an undefined value at 
/Library/Perl/5.8.6/Catalyst/Model/CDBI.pm line 67." at 
/Library/Perl/5.8.6/Module/Pluggable/Fast.pm line 95
Compilation failed in require at script/app_server.pl line 13.
BEGIN failed--compilation aborted at script/app_server.pl line 13.


If I get rid of the overridden new() everything loads fine.

Everything should be fairly up to date, just installed Catalyst a few 
days ago...

Any ideas?



More information about the Catalyst mailing list