[rt-devel] script to test for keyword ?

Alan Horn ahorn at deorth.org
Tue Dec 9 21:48:21 EST 2003


On Tue, 9 Dec 2003, Alan Horn wrote:

>Date: Tue, 9 Dec 2003 14:32:55 -0800 (PST)
>From: Alan Horn <ahorn at deorth.org>
>To: darren chamberlain <darren at boston.com>
>Cc: rt-devel at lists.fsck.com
>Subject: Re: [rt-devel] script to test for keyword ?
>
>
>On Tue, 9 Dec 2003, darren chamberlain wrote:
>
>>Date: Tue, 9 Dec 2003 09:54:51 -0500
>>From: darren chamberlain <darren at boston.com>
>>To: rt-devel at lists.fsck.com
>>Subject: Re: [rt-devel] script to test for keyword ?
>>
>>* Alan Horn <ahorn at deorth.org> [2003/12/08 15:30]:
>>> sub IsApplicable {
>>>     my $self = shift;
>>>     if ($self->TicketObj->KeywordSelect-2 eq '1.5') {
>>                            ^^^^^^^^^^^^^^^
>>
>>Perl identifiers are limited to alphanumics and underscores, so this
>>will be interpreted as:
>>
>>  if (($self->TicketObj->KeywordSelect) - 2) eq '1.5') {
>>
>>which is probablt not what you mean.
>>
>>(darren)
>>
>>
>
>Looking more closely at the perldoc for Ticket, I realise that
>KeywordSelect-2 is not a method (aside from the perl brokenness I put in
>there ;)
>
>So, my question is, what method would I call to pull the keywords out of a
>transaction ?
>

Wel, after much head banging I finally came up with this :

sub IsApplicable {
    my $self = shift;
    ## 2 is the 'Phase' keyword in KeywordSelects table
    my $SELECTID = 2;
    ## 7 is the number for 1.0
    my $CHILDID = 7;
    if ($self->TicketObj->KeywordsObj($SELECTID)->HasEntry($CHILDID)) {
        return(1);
    }
    else {
        return(undef);
    }
}

Which is a pretty non portable way to do it I guess.. I have a separate
scrip for CHILDID = 8 (the other descendant of phase), and a third scrip
for the case where neither keyword is selected (to provide a suitable
default action)

I'm also very worried about the HasEntry method, since it's from a module
that is outside the API and shouldn't be used.

Is this a reasonable way to be going about this do you think ? Is there a
cleaner or more general approach ?

Cheers,

Al

p.s. all my earlier head banging was due to the HTML being borked (I'd
moved the keywords box.. or rather.. I hadn't really.. there were two
copies of it and the one on the 'Details' page of Create.html was
overriding and wiping out my selections)

A duh moment.. :)




More information about the Rt-devel mailing list