Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Catalyst: Users

auto-generate ResultSet classes?

 

 

Catalyst users RSS feed   Index | Next | Previous | View Threaded


jarom at jaromsmith

May 27, 2009, 5:31 PM

Post #1 of 6 (993 views)
Permalink
auto-generate ResultSet classes?

Sorry, one more question (and this one does have to do with Catalyst
more than DBIC, I think...)

Is there any magical invocation for the create script which will make a
bunch of stub ResultSet classes for me, similar to how the Result
classes are auto-generated when I do

script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema
create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp
'dbuser' 's3kr1t' '{ AutoCommit => 1 }'

? (and if so, what is it?)

thanks,

jarom smith
tech go-to guy

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


jshirley at gmail

May 27, 2009, 5:58 PM

Post #2 of 6 (921 views)
Permalink
Re: auto-generate ResultSet classes? [In reply to]

On Wed, May 27, 2009 at 5:31 PM, Jarom Smith <jarom [at] jaromsmith> wrote:

> Sorry, one more question (and this one does have to do with Catalyst more
> than DBIC, I think...)
>
> Is there any magical invocation for the create script which will make a
> bunch of stub ResultSet classes for me, similar to how the Result classes
> are auto-generated when I do
>
> script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema
> create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp 'dbuser'
> 's3kr1t' '{ AutoCommit => 1 }'
>
> ? (and if so, what is it?)
>
> thanks,
>
> jarom smith
> tech go-to guy
>
>
What do you want/expect the resultset classes to contain? Or do you want a
resultset class created for every result source?

I've found that using a custom resultset default via load_namespaces suits
most of my needs, but I'd be interested to hear other scenarios.

Thanks,
-J


jarom at jaromsmith

May 27, 2009, 6:52 PM

Post #3 of 6 (910 views)
Permalink
Re: auto-generate ResultSet classes? [In reply to]

Yes, I was thinking a very simple stub ResultSet class for every Result
source. Something like:

package MyApp::Schema::ResultSet::MyTable;

use strict;
use warnings;

use base 'DBIx::Class::ResultSet';

# example
#sub get_by_id {
# my $self = shift;
# my $id = shift;
#
# return $self->find($id)->all;
#}

1;

In practice, it may be overkill to create a ResultSet class for each
Result class, and admittedly it's not too difficult to create these
ResultSet classes by just doing one and copying as needed. I'm probably
being lazier than I should be...


jarom smith
tech go-to guy


J. Shirley wrote:
> On Wed, May 27, 2009 at 5:31 PM, Jarom Smith <jarom [at] jaromsmith
> <mailto:jarom [at] jaromsmith>> wrote:
>
> Sorry, one more question (and this one does have to do with Catalyst
> more than DBIC, I think...)
>
> Is there any magical invocation for the create script which will
> make a bunch of stub ResultSet classes for me, similar to how the
> Result classes are auto-generated when I do
>
> script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema
> create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp
> 'dbuser' 's3kr1t' '{ AutoCommit => 1 }'
>
> ? (and if so, what is it?)
>
> thanks,
>
> jarom smith
> tech go-to guy
>
>
> What do you want/expect the resultset classes to contain? Or do you
> want a resultset class created for every result source?
>
> I've found that using a custom resultset default via load_namespaces
> suits most of my needs, but I'd be interested to hear other scenarios.
>
> Thanks,
> -J
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> List: Catalyst [at] lists
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
> Dev site: http://dev.catalyst.perl.org/

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


jshirley at gmail

May 27, 2009, 7:07 PM

Post #4 of 6 (910 views)
Permalink
Re: auto-generate ResultSet classes? [In reply to]

On Wed, May 27, 2009 at 6:52 PM, Jarom Smith <jarom [at] jaromsmith> wrote:

> Yes, I was thinking a very simple stub ResultSet class for every Result
> source. Something like:
>
> package MyApp::Schema::ResultSet::MyTable;
>
> use strict;
> use warnings;
>
> use base 'DBIx::Class::ResultSet';
>
> # example
> #sub get_by_id {
> # my $self = shift;
> # my $id = shift;
> #
> # return $self->find($id)->all;
> #}
>
> 1;
>
> In practice, it may be overkill to create a ResultSet class for each Result
> class, and admittedly it's not too difficult to create these ResultSet
> classes by just doing one and copying as needed. I'm probably being lazier
> than I should be...
>
>
> jarom smith
> tech go-to guy
>
>
> J. Shirley wrote:
>
>> On Wed, May 27, 2009 at 5:31 PM, Jarom Smith <jarom [at] jaromsmith<mailto:
>> jarom [at] jaromsmith>> wrote:
>>
>> Sorry, one more question (and this one does have to do with Catalyst
>> more than DBIC, I think...)
>>
>> Is there any magical invocation for the create script which will
>> make a bunch of stub ResultSet classes for me, similar to how the
>> Result classes are auto-generated when I do
>>
>> script/myapp_create.pl model MyAppDB DBIC::Schema MyApp::Schema
>> create=static components=TimeStamp,EncodedColumn dbi:mysql:myapp
>> 'dbuser' 's3kr1t' '{ AutoCommit => 1 }'
>>
>> ? (and if so, what is it?)
>>
>> thanks,
>>
>> jarom smith
>> tech go-to guy
>>
>>
>> What do you want/expect the resultset classes to contain? Or do you want
>> a resultset class created for every result source?
>>
>> I've found that using a custom resultset default via load_namespaces suits
>> most of my needs, but I'd be interested to hear other scenarios.
>>
>> Thanks,
>> -J
>>
>>

Catalyst::Helper::Model::DBIC::Schema doesn't do that, but you could submit
a patch :)

-J


jarom at jaromsmith

May 29, 2009, 11:38 AM

Post #5 of 6 (866 views)
Permalink
Re: auto-generate ResultSet classes? [In reply to]

J. Shirley wrote:
> Catalyst::Helper::Model::DBIC::Schema doesn't do that, but you could
> submit a patch :)

I know, I need to contribute as well as take away.

If I were to do this, I think I would probably just extend the current
auto-generation mechanism that creates stuff in the Result directory to
create analogous stub files in a ResultSet directory... but I need to
become more familiar with this stuff first and make sure that such a
change actually makes sense. At this point I'm still getting my bearings.

jarom smith
tech go-to guy

_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/


bobtfish at bobtfish

May 30, 2009, 7:40 AM

Post #6 of 6 (864 views)
Permalink
Re: auto-generate ResultSet classes? [In reply to]

On 29 May 2009, at 19:38, Jarom Smith wrote:

>
>
> J. Shirley wrote:
>> Catalyst::Helper::Model::DBIC::Schema doesn't do that, but you
>> could submit a patch :)
>
> I know, I need to contribute as well as take away.
>
> If I were to do this, I think I would probably just extend the
> current auto-generation mechanism that creates stuff in the Result
> directory to create analogous stub files in a ResultSet
> directory... but I need to become more familiar with this stuff
> first and make sure that such a change actually makes sense. At
> this point I'm still getting my bearings.

That would be doable as suggested - you'd patch the
DBIx::Class::Schema::Loader, then the Catalyst model to know about
those options.


Cheers
t0m


_______________________________________________
List: Catalyst [at] lists
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/catalyst [at] lists/
Dev site: http://dev.catalyst.perl.org/

Catalyst users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.