[Dbix-class] Create Components that operate on ResultSets

John Napiorkowski jjn1056 at yahoo.com
Sat Oct 21 06:00:49 CEST 2006



--- Matt S Trout <dbix-class at trout.me.uk> wrote:

> John Napiorkowski wrote:
> > Hi,
> > 
> > I have a generic resultset class that is not at
> all
> > specific to a particular table.  I use it for
> getting
> > query parameters and filtering a resultset by page
> > number, max results and so forth.  Right now I
> load it
> > in each Schema that uses it like so:
> > 
> >
>
__PACKAGE__->resultset_class('DBIx::Class::ResultSetByQuery');
> > 
> > But I'm trying to figure out a way to include it
> in
> > all my Schemas by default.  All my Schemas inherit
> > from a base.pm schema for loading components, but
> if I
> > put the __PACKAGE__->resultset_class in that I get
> the
> > following error:
> > 
> > Can't locate object method
> "result_source_instance"
> > via package "membership::Schema::base" at
> >
>
/usr/lib/perl5/site_perl/5.8.5/DBIx/Class/ResultSourceProxy.pm
> > line 10.
> > 
> > I'd like to make this a more generic component
> since I
> > figure other people might be able to use it.  But
> I
> > can't find out how to make it a componant that
> loads
> > via __PACKAGE__->load_components().  I can't seem
> to
> > figure out how to create a resultset component. 
> Can
> > anyone point me toward a good example of this? 
> Seems
> > most of the components are oriented toward
> operating
> > on rows.
> 
> Wrap sub table() to set the resultset_class
> afterwards?
> 
> Something like
> 
> sub table {
>    my $class = shift;
>    $class->next::method(@_);
>    my $source = $class->result_source_instance;
>    if ($source->resultset_class eq
> 'DBIx::Class::ResultSet') {
>     
> $source->resultset_class('My::Custom::ResultSet');
>    }
> }

Well, didn't seem to do it (or I'm not using it
properly, which just as easily could be the case).

It might just be a case of me trying to do something I
shouldn't do.  Since it is a custom resultset I can
get it installed with
__PACKAGE__->resultset_class(...) or with
__PACKAGE__->load_resultset_components for the Schemas
I'm using the ResultSetManager for (which by the way
is working very well for me despite being marked as
experimental.)  It's just that I end up putting that
line in every single table that uses the global search
and for some reason I can't put in in my base Schema
class without it generating errors.

Thanks!
John

> 
> -- 
>       Matt S Trout       Offering custom
> development, consultancy and support
>    Technical Director    contracts for Catalyst,
> DBIx::Class and BAST. Contact
> Shadowcat Systems Ltd.  mst (at)
> shadowcatsystems.co.uk for more information
> 
> + Help us build a better perl ORM:
> http://dbix-class.shadowcatsystems.co.uk/ +
> 
> _______________________________________________
> List:
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/dbix-class
> Wiki: http://dbix-class.shadowcatsystems.co.uk/
> IRC: irc.perl.org#dbix-class
> SVN:
>
http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
> Searchable Archive:
>
http://www.mail-archive.com/dbix-class@lists.rawmode.org/
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Dbix-class mailing list