[Catalyst] Models Inheriting from Catalyst::Base

David Storrs dstorrs at dstorrs.com
Thu Nov 17 22:12:46 CET 2005


On Nov 17, 2005, at 3:56 PM, Brandon Black wrote:
>
> Inheriting your Model from Catalyst::Model::* does not give your Model
> access to $c, but it does give your controllers access to your Model
> via:
>
> $c->comp('App::M::CDBI::MyTable')->a_table_method();
>
> as opposed to otherwise just using:
>
> App::M::CDBI::MyTable->a_table_method();
>
> directly.  I don't yet understand the advantage of using $c->comp() at
> all, either. [...]

Well, you could do this:

$c->comp( fetch_table_name(@some_params) )->a_table_method();


At the least, that allows you to hardcode your table name in only one  
place in only one file.  For a little more whiz-bang, you could  
determine the table name dynamically based on @some_params.

--Dks



More information about the Catalyst mailing list