Callback Ticket/ShowHistory/SkipTransaction gives 'return 1; '

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Thanks to all who have assisted me in getting started with callbacks.
While I understand the principle by which the mechanism works, I’m not
getting what I expect, at all. I’m running this on RT 3.6.1.

My callback code is called from Ticket/ShowHistory:

while ( my $Transaction = $Transactions->Next ) {
my $skip = 0;
$m->comp( ‘/Elements/Callback’,
_CallbackName => ‘SkipTransaction’,
Transaction => $Transaction,
skip => $skip,
%ARGS );
next if $skip;
$i++;

The callback code has been placed in the file
’/opt/rt3/local/html/Callbacks/MyCallbacks/Ticket/Elements/ShowHistory/SkipTransaction’
and the web server restarted. To ensure I’m on the right track, I copied
SkipTransaction from RTIR and altered it so that presumably, I should be
skipping all history transactions:

<%INIT>

Set $skip to 1 if transaction matches criteria

$skip is passed by reference

return $$skip = 1;

</%INIT>
<%ARGS>
$skip => undef
$Transaction => undef
</%ARGS>

When I look at any ticket, I get

return 1;
…First transaction on the ticket …
return 1;
…Next transaction on the ticket …

[etc]

What I would expect is that there would be no history transactions
displayed. In fact, if I boil the code down to:

<%INIT>
</%INIT>

I still get that result. It I copy the SkipTransaction code from RTIR
verbatim get that result. I have been looking over all of the callback
code that I can find on the web and see nothing that gives me any clue.
Obviously, the callback mechanism works well and the problem is my lack
of knowledge on this topic. What am I missing here?

Thanks very much!

Barry

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFFLlaQCFu3bIiwtTARAgr3AJ0Rb1zQcXo0wjChQ4rcIKI5t4QUUQCeMY+D
EsEixJuIR3yJrLdEIMS6j0I=
=MpF1
-----END PGP SIGNATURE-----

-----Original Message-----
Thanks to all who have assisted me in getting started with callbacks.
While I understand the principle by which the mechanism works, I’m not
getting what I expect, at all. I’m running this on RT 3.6.1.

My callback code is called from Ticket/ShowHistory:

while ( my $Transaction = $Transactions->Next ) {
my $skip = 0;
$m->comp( ‘/Elements/Callback’,
_CallbackName => ‘SkipTransaction’,
Transaction => $Transaction,
skip => $skip,
%ARGS );
next if $skip;
$i++;

<%INIT>

Set $skip to 1 if transaction matches criteria

$skip is passed by reference

return $$skip = 1;

</%INIT>
<%ARGS>
$skip => undef
$Transaction => undef
</%ARGS>

When I look at any ticket, I get

return 1;
…First transaction on the ticket …
return 1;
…Next transaction on the ticket …

Barry,

Perhaps your mason cache needs to be cleaned out? The only way I can see
that you would get that result is if the SkipTransaction callback was this:

return 1;
<%ARGS>
$skip => undef
$Transaction => undef
</%ARGS>

Did you have something like that in an earlier iteration? Incidentally, you
don’t need to return a value here, just set $$skip.

Good luck,
Steve

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stephen Turner wrote:

Barry,

Perhaps your mason cache needs to be cleaned out? The only way I can see
that you would get that result is if the SkipTransaction callback was this:

return 1;
<%ARGS>
$skip => undef
$Transaction => undef
</%ARGS>

Did you have something like that in an earlier iteration? Incidentally, you
don’t need to return a value here, just set $$skip.

Hi Steve.

That’s kind of what I gathered. If I’m getting this right, anything
between <%INIT> and </%INIT> is executed as code. Anything outside of
these tags is sent to the browser stream. As a test, I tried putting a
"Hello, World" where you have the “return 1” but did not get it in the
output. So that leads me to believe that you may be right, it may be a
mason cache thing.

I’ll try clearing that and see what happens. Thanks for the reply!

Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFFLmGnCFu3bIiwtTARApp+AKCez5wwc68h8LjRowNVb7PEXROu7wCgl8al
MDWY9+kU/IMUtH+ZJGrLDdc=
=vDaI
-----END PGP SIGNATURE-----

-----Original Message-----
From: Barry L. Kline

Hi Steve.

That’s kind of what I gathered. If I’m getting this right, anything
between <%INIT> and </%INIT> is executed as code. Anything outside of
these tags is sent to the browser stream. As a test, I tried
putting a
"Hello, World" where you have the “return 1” but did not get it in the
output. So that leads me to believe that you may be right,
it may be a
mason cache thing.

I’ll try clearing that and see what happens. Thanks for the reply!

Barry

Barry,

If this isn’t a production system, there’s a config setting
(RT_SiteConfig.pm) that should allow mason component changes to be effective
instantly, without web server restart or cache clearing:

Set($DevelMode => ‘1’);

Makes development a little less tiresome. It apparently slows things down a
little so you want to make sure this is turned off in your production
systems.

Steve

Stephen Turner
Senior Programmer/Analyst - Client Support Services
MIT Information Services and Technology (IS&T)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Stephen Turner wrote:

Barry,

If this isn’t a production system, there’s a config setting
(RT_SiteConfig.pm) that should allow mason component changes to be effective
instantly, without web server restart or cache clearing:

Set($DevelMode => ‘1’);

Makes development a little less tiresome. It apparently slows things down a
little so you want to make sure this is turned off in your production
systems.

That was the problem Steve. Thanks very much! My final code is this:

<%INIT>

Set $skip to 1 if transaction matches criteria

$skip is passed by reference

get out of here asap

unless ( $Transaction->Field eq ‘Priority’ && $Transaction->Type eq ‘Set’) {
return $$skip = 0;
}

$$skip = 1;

</%INIT>

<%ARGS>
$skip => undef
$Transaction => undef
</%ARGS>

and now I don’t have to look at any more “Set Priority” messages, which
is just what I wanted.

I really appreciate your help.

Barry
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)

iD8DBQFFLmgaCFu3bIiwtTARAr08AJ98VDAjAhnoy7WSn+1VY3EpI0+wVgCglE6O
znimQ/+nSRiNz38cCgMKsuk=
=PEmy
-----END PGP SIGNATURE-----