[Catalyst] Search example in any docs?
J. Shirley
jshirley at gmail.com
Wed Sep 24 01:45:17 BST 2008
On Tue, Sep 23, 2008 at 4:34 PM, Dr. Jennifer Nussbaum
<bg271828 at yahoo.com> wrote:
>
> --- 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.
>
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
More information about the Catalyst
mailing list