[Catalyst] More new shortcuts

Jules Bean jules at jellybean.co.uk
Sun Nov 6 20:46:05 CET 2005


Sebastian Riedel wrote:
> Small usability improvement today, we've just added $c->controller, 
> $c->model and $c->view as shortcuts for $c->component.
>
> Examples:
>
>     $c->model('DBIC::FooTable')->find(1);
>     $c->model('Xapian')->search(...);
>     $c->forward( $c->view('TT') );
>     [% FOR result = c.model('DBIC::BarTable')->search(...) %]

Am I not right in thinking that this will only work if the component 
inherits from Catalyst::Base or at least one of its new friends? It's 
only for them that the automatic instantation in Setup occurs?

I think there's a real potential source of confusion here. For example, 
a classic catalyst view or controller is typically a singleton object, 
and one can get away with confusing class and unique instance. However, 
a CDBI or DBIC model doesn't work like this: an instance represents a 
tuple (row if you prefer) in the database. So what 'instance' would 
C->model() return?

Jules



More information about the Catalyst mailing list