[Catalyst] Models Inheriting from Catalyst::Base

Matt S Trout dbix-class at trout.me.uk
Sat Nov 19 02:44:59 CET 2005


On Fri, Nov 18, 2005 at 01:10:53PM -0500, Jonathan Manning wrote:
> 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.

Not going to work with DBIx::Class, which actually uses 'new' to create an
object - not one in the database yet (which Class::DBI can't handle at all :)
but one one which ->insert can be called later. The DBIx::Class ->create
is almost exactly equivalent to sub create { shift->new(@_)->insert; }
 
> I've been meaning to get around to switching to DBIC myself, so I'm
> interested to hear what happens.

Neither of the DBIx::Class models for Catalyst have your table classes
inheriting from the main model class, so the situation should be largely
moot.

-- 
     Matt S Trout       Specialists in Perl consulting, web development, and
  Technical Director    UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list