[Catalyst] Some guidance needed please
Ash Berlin
ash_cpan at firemirror.com
Thu Sep 13 21:02:51 GMT 2007
Simon Wilcox wrote:
> Matt S Trout wrote:
>> On Thu, Sep 13, 2007 at 03:14:58PM +0100, Ian Docherty wrote:
>>> Almost, if I do my $used_password =
>>> $c->model('DBIC::UsedPassword')->result_class->create_limited();
>>>
>>> it works. So that should do for now, thanks Simon and Will for your help ;)
>> No. Don't do that.
>>
>> Really don't.
>>
>> It's utterly broken.
>
> Thanks. I'm not as familiar with the interaction of DBIx::Class and
> Catalyst::Model::* as you are (obviously, I didn't write 'em :) but from
> here:
>
> http://search.cpan.org/~ash/DBIx-Class-0.08007/lib/DBIx/Class/ResultSet.pm#result_class
>
> I find:
>
> result_class
>
> Arguments: $result_class?
> Return Value: $result_class
>
> An accessor for the class to use when creating row objects.
> Defaults
> to result_source->result_class - which in most cases is the name of
> the "table" class.
>
> This seems to be the right behaviour to me. Can you summarise why it is
> not ?
>
> Yet over here:
>
> http://search.cpan.org/~blblack/Catalyst-Model-DBIC-Schema-0.20/lib/Catalyst/Model/DBIC/Schema.pm
>
> I find:
>
> class
>
> Shortcut for ->schema->class
>
>
> So would the original be better written as:
>
> $c->model('DBIC::UsedPassword')->class->create_limited(); # ?
>
Wouldn't it just be nicer if you could do:
$c->model('DBIC::UsedPassword')->create
Create a new class that inherits from DBIx::Class::ResultSet. then do
__PACKAGE__->resultset_class('...::ResultSet::UsedPassword');
In your source class.
Nicer, no?
More information about the Catalyst
mailing list