On Tue, Sep 23, 2008 at 4:34 PM, Dr. Jennifer Nussbaum <[EMAIL PROTECTED]> wrote: > > --- On Tue, 9/23/08, Tomas Doran <[EMAIL PROTECTED]> wrote: > >> From: Tomas Doran <[EMAIL PROTECTED]> >> Subject: Re: [Catalyst] Search example in any docs? >> To: [EMAIL PROTECTED], "The elegant MVC web framework" >> <catalyst@lists.scsys.co.uk> >> Date: Tuesday, September 23, 2008, 3:41 PM >> On 23 Sep 2008, at 21:21, Dr. Jennifer Nussbaum wrote: >> > i have >> > code that looks like >> > >> > if ( $c->req->params->{title} ) { >> > my $title = "%" . >> $c->req->params->{title} . "%"; >> > push (@$query, { title => { like => $title } >> }); >> > } >> > >> > # exact match here >> > if ( $c->req->params->{author} ) { >> > my $performer = >> $c->req->params->{author}; >> > push (@$query, { author => { '=' => >> $author} }); >> > } >> > >> > etc., which just looks messy. >> >> It's called refactoring - pull the common bits out and >> put them in a >> base class for your controllers. > > Thanks. I do appreciate this, and its a neat solution, but the problem wasnt > that i dont know how to put common elements in a base class, the > problem is that nowhere in the Cat docs, formal or informal, are there any > examples of doing searches with web apps. >
Right, because any solution would be model specific. Which puts it in the realm of wiki nodes or CatalystX modules that profess preference for an ORM model. > In practice i tend to have more complicated apps, with difficult queries, > that i do abstract out the query building, and then things that i > throw together in a few minutes where everythings a mess. Usually when im > just throwing things together, i forget about best practices and want > to look them up. > > Jen > Wiki! Wiki! Document what you've done and post on here. Wiki nodes are a living document and can evolve with time and evolve into better solutions. What you're asking for is more a model, though, not Catalyst (which is just a framework, no more, no less). -J _______________________________________________ List: Catalyst@lists.scsys.co.uk Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/ Dev site: http://dev.catalyst.perl.org/