[Catalyst] CDBI::Plain - workaround for failing classes.
Jonathan Manning
jmanning at alisa-jon.net
Fri Aug 5 20:12:20 CEST 2005
(sorry for the previous dup - didn't realize I had already sent it)
After looking at my CDBI problems long and hard, I came up with a
workaround for the issues I was having. I suspect it points to the cause
of the problems - I'd guess it's related to inheritance.
Below, Obj::* refers to my non-Catalyst CDBI Object classes.
Class that fails: (as per example 2 in CDBI::Plain)
package MyApp::M::MyTable;
use base qw[Catalyst::Model::CDBI::Plain MyApp::Obj::MyTable];
1;
Class that works: (Update the example to this?)
package MyApp::M::MyTable;
# swapped order of base classes
use base qw[MyApp::Obj::MyTable Catalyst::Model::CDBI::Plain];
sub new {
# Prevents Class::DBI->new from being called.
Catalyst::Model::CDBI::Plain->new(@_);
}
1;
What I think is happening is that when a call is made to a method in my
model class, the inheritance is followed (depth-first, left-to-right) as
such:
1. MyApp::M::MyTable
2. -> Catalyst::Model::CDBI::Plain
3. -> -> Class::DBI (stuff I'm trying to override in MyTable)
4. -> -> Catalyst::Base
5. -> MyApp::Obj::MyTable (table, columns, has_a, etc)
6. -> -> MyApp::Obj::RootCDBI (connect)
7. -> -> -> Class::DBI (Where it usually falls in the inheritance)
[...]
So, any methods I override in Class:DBI in my Obj class are ignored,
since Class::DBI is resolved first. I suspect this is the source of my
missing metadata.
Switching around the base classes fixes this, except for the call to
new, which is manually redirected to Catalyst.
Thoughts? If this can be verified, can the example be updated?
~J
More information about the Catalyst
mailing list