[Catalyst] Models Inheriting from Catalyst::Base
Jonathan Manning
jmanning at alisa-jon.net
Fri Nov 18 19:10:53 CET 2005
Nigel Metheringham wrote (edited):
> So I added a Catalyst::Base into the user base line of the parent class
> of my models.... and was eaten by a grue :-/
>
> package BroadsoftFeature::M::Db::Base::DBIC;
> use base qw/Catalyst::Base DBIx::Class/;
>
> and I now get
> Couldn't instantiate component
> "BroadsoftFeature::M::Db::FeatureGroup", "Can't use string
> ("BroadsoftFeature") as a HASH ref while "strict refs" in use
> at /usr/local/share/perl/5.8.7/DBIx/Class/InflateColumn.pm line
> 71." at /usr/local/share/perl/5.8.7/Module/Pluggable/Fast.pm
> line 95
>
> Does this ring any bells for people?
Yes, I've encountered similar difficulties, though with CDBI, not DBIC.
Try switching the order of inheritance to:
use base qw/DBIx::Class Catalyst::Base/;
Catalyst seems to conflict with some essential model methods in CDBI
(and possibly DBIC). Even with nextalizer, I've never been able to find
the source of the problem.
With the order switched, your model classes should work again, but it
does break at least one thing - the new method for Catalyst. I also had
to write a new method in my model base class to prevent new from being
called on CDBI/DBIC.
sub new {
return Catalyst::Base::new(@_);
}
Caveat: I am not a Catalyst Internals Hacker, so I don't know what other
breakage this might cause. This is what I had to do to get it to work
and is merely my best guess. That said, it works for me with CDBI.
I've been meaning to get around to switching to DBIC myself, so I'm
interested to hear what happens.
~Jonathan
More information about the Catalyst
mailing list