--- 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"
> <[email protected]>
> 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
_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/