[ic] Problems using SearchOp

Stefan Hornburg racke at linuxia.de
Wed Jul 5 10:15:29 EDT 2006


Tim Good wrote:
>>-----Original Message-----
>>From: interchange-users-bounces at icdevgroup.org 
>>[mailto:interchange-users-bounces at icdevgroup.org] On Behalf 
>>Of Kevin Walsh
>>Sent: Wednesday, July 05, 2006 6:37 AM
>>To: interchange-users at icdevgroup.org
>>Subject: Re: [ic] Problems using SearchOp
>>
>>"Tim Good" <tim.g at edsd.com> wrote:
>>
>>>I am trying to create my own op for searching on $somedate ge than 
>>>today.
>>>Folling directions at:
>>>http://www.icdevgroup.org/pipermail/interchange-users/2005-A
>>>pril/042874.html
>>>Which differ slightly from:
>>>http://www.icdevgroup.org/interchange-doc-5.2.0/frames/icdat
>>>abase_32.html
>>>
>>>Interchange: 5.4.1 stable, Perl: Perl 5.8.7 non-threaded 
>>
>>Here is what 
>>
>>>I put in my catelog.cfg :
>>>
>>>## Custom search op for greater than todays date ## used to filter 
>>>auctions which haven't started yet ## from search results.
>>>CodeDef auctionstart SearchOp
>>>CodeDef auctionstart Routine <<EOR
>>>sub {
>>>      my ($self, $i, $pat) = @_;
>>>      $pat = reverse($pat);
>>>      $pat = qr($pat)i;
>>>
>>>      return sub {
>>>              my $itemstart = shift;
>>>              return ($itemstart ge "2006-07-03 00:00:00");
>>>      };
>>>}
>>>
>>
>>You don't need the two $pat lines in there, by the way.  They 
>>were useful in the code you copied/pasted but are not used at 
>>all in your code.
> 
> Thanks for pointing this out. I had realized that.
> 
> 
>>On the other hand, you might want to pass your date string in 
>>as a mv_searchspec (se=yourdatestring), and capture that in 
>>$pat, instead of hard-coding the value in your code.
>>
> 
> This was exactly my original thoughts but hard coded it to lessen the 
> Troubleshooting points.
> 
> 
>>>And the error I get is:
>>>
>>> search error: Limit subroutine creation: Can't use an 
>>
>>undefined value 
>>
>>>as an ARRAY reference at /usr/local/interchange/lib/Vend/Search.pm 
>>>line 653.
>>>
>>
>>Try this patch:
>>
>>*** lib/Vend/Search.pm- Wed Jul  5 12:44:01 2006
>>--- lib/Vend/Search.pm  Wed Jul  5 13:30:27 2006
>>***************
>>*** 649,656 ****
>>                $c->[$i] =~ tr/ \t//;
>>                my $o = $c->[$i];
>>                $c->[$i] = $s->{mv_numeric}[$i]
>>!                               ? [ @{$numopmap{$o}} ]
>>!                               : [ @{$stropmap{$o}} ];
>>                if(! $c->[$i]) {
>>                        my $r;
>>                        $c->[$i] = [$r, $o], next
>>--- 649,656 ----
>>                $c->[$i] =~ tr/ \t//;
>>                my $o = $c->[$i];
>>                $c->[$i] = $s->{mv_numeric}[$i]
>>!                               ? $numopmap{$o}
>>!                               : $stropmap{$o};
>>                if(! $c->[$i]) {
>>                        my $r;
>>                        $c->[$i] = [$r, $o], next
>>
>>The dereference and re-reference seems wasteful to me, and is 
>>the cause of the problem you reported.  If there's a reason 
>>for doing that, and I can't see one, then it can be done 
>>later in the code.
>>
> 
> Kevin thank you for you time in figuring out the patch.That is exactly
> What the doctor ordered. Cheers!

It would be nice if you can post your finished SearchOp here, so
people can see a real world example in the archives.

Bye
	Racek

-- 
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team



More information about the interchange-users mailing list