[Catalyst] Search example in any docs?

Dr. Jennifer Nussbaum bg271828 at yahoo.com
Wed Sep 24 00:34:44 BST 2008


--- On Tue, 9/23/08, Tomas Doran <bobtfish at bobtfish.net> wrote:

> From: Tomas Doran <bobtfish at bobtfish.net>
> Subject: Re: [Catalyst] Search example in any docs?
> To: bg271828 at yahoo.com, "The elegant MVC web framework" <catalyst at 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.

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


      



More information about the Catalyst mailing list