[Maypole-dev] default search behavior? evil caller() checking.

From: Kevin Connor (kconnor at proofpoint.com)
Date: Tue Oct 26 2004 - 18:28:27 BST


Maypole::Model::CDBI::search keeps all the empty params as valid search
params, so unless every field in the search form has valid values (or if
the db actually has records with null values for the null criteria) the
search won't find anything.

This doesn't seem right to me.

A small change to M::MM::CDBI::search ignores the empty string params.

However, it seems to be easier to keep the base behavior as is and
override it with a search method in an application class (say Beer.pm)
that strips out the empty params:

sub search : Exported
{
     #ignore blank fields in search form
     my ( $self, $r ) = @_;
     my %params = %{ $r->{params} };
     map { delete $params{$_} if (!defined $params{$_} || $params{$_} eq
'') } keys %params;
     $r->{params} = \%params;
 

     return $self->SUPER::search($r);
}

But this won't work because of this evil line in M::MM::CDBI::search():

return shift->SUPER::search(@_) if caller ne "Maypole::Model::Base";

Any idea what this line is for? It seems bad form to check the caller.

-Kevin

_______________________________________________
maypole-dev mailing list
maypole-dev at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole-dev



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT