[Catalyst-dev] Problems with $c->model() and _comp_singular()

Brandon Black blblack at gmail.com
Tue Aug 8 18:11:25 CEST 2006


On 8/8/06, Jonas <jonas.alves at gmail.com> wrote:
>
> Maybe $c->model should return the DBIC model schema if it founds one.
> That way if you have a DBIC Model schema named MyApp::Model::Foo and
> want to get the Bar resultset you just have to write
> $c->model->resultset('Bar') instead of
> $c->model('Foo')->resultset('Bar'). I know that you can write
> $c->model('Foo::Bar'); but the other form is useful if you don't know
> the model name. In the new instantCRUD it's possible to define the
> model name in the helper but than i don't know what name the user as
> chosen so i can't have it hardcoded in the base controllers. What i
> did to circumvent that was to write the model name in the generated
> app config.


Well, the Catalyst.pm code can't be specific to the DBIC Schema model.
There are many other models out there for Cat, some of which have nothing to
do with databases.  About the only way to make such a thing work out well
would be to add a peice of class/instance data to each model that indicates
whether it is a "submodel" of some other model or not.  Then models like
DBIC::Schema could set this flag on the resultset pseudo-models to exclude
them from the search process for $c->model.  It all seems like too much
effort in the name of too little useful magic to me, but that's up to
everyone else.

-- Brandon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.rawmode.org/pipermail/catalyst-dev/attachments/20060808/550fc493/attachment-0001.htm 


More information about the Catalyst-dev mailing list