[Catalyst] More new shortcuts

Jules Bean jules at jellybean.co.uk
Sun Nov 6 21:18:04 CET 2005


Sebastian Riedel wrote:
> It works for all components that inherit from a Catalyst::Component 
> subclass, which are Catalyst::Base and the new Catalyst::Controller, 
> Catalyst::Model, Catalyst::View.

Some people recommend not to inherit from any of these for your model 
class, so that the model can be used outside Catalyst in batch scripts etc.

>> 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?
>
> $c->components stores a instance of each loaded component (see Loaded 
> Components table on startup).
> Even DBIC/CDBI models have such a instance, it's really not complicated.

I've read the code, I understand what happens. It may not be complicated 
but I find it confusing. What is the purpose of these instances? (I'm 
not trying to be difficult, I am genuinely trying to understand) What is 
the advantage of $unique_instance->foo() over Class::Name->foo()?

Jules



More information about the Catalyst mailing list