On Fri, Jun 22, 2007 at 10:04:49AM +1000, Charlie Garrison wrote:
> Good morning,
> 
> On 22/6/07 at 8:37 AM +0930, Jon Schutz <[EMAIL PROTECTED]> wrote:
> 
> >> So, first my question is, what is the best way to extend 
> >>find so  that I can restrict records using an additional 
> >>(constant) value  in the query? And if I should just override 
> >>'find', where do I  put my 'find' method?
> >
> >find is a ResultSet method; you need to create a ResultSet class that
> >inherits from DBIx::Class::ResultSet, put your find in there (and
> >probably search_rs too), and direct your schema to use that class by
> >adding
> >__PACKAGE__->resultset_class(...)
> >
> >into your schema (table declaration) class.
> 
> I found a similar explanation in the cookbook, but didn't think 
> that applied in this case (not sure why). Now that you've 
> clarified it, it makes perfect sense. I'll give that a go now.

Yeah, but it's still not what you want - you don't want to be overloading
find(), you want to be making sure the resultset you end up with has already
had the ->search applied to it, like I said in my previous e-mail.

Assuming you're doing this for user permission restrictions, you might
want a look at DBIx::Class::Schema::RestrictWithObject ...

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director    Want a managed development or deployment platform?
 Shadowcat Systems Ltd.  Contact mst (at) shadowcatsystems.co.uk for a quote
http://chainsawblues.vox.com/             http://www.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/[email protected]/

Reply via email to