|
TT wizards,
I�ve ran into a weird and
strange situation using TT on two different machines A and B. I recently moved
one of my own modules from one RedHat system to another. Both A and B have TT
2.11 installed, A is running Perl 5.6.1 and B Perl 5.6.0. I�ve isolated my problematic
code and template down to a few lines, and it looks like this (SKdb is my
module, code unchanged between the two machines): # test.pl
-------------------------- use
SKdb; use
Template; my %vars =
(); $vars{LARTS} =
\&SKdb::dbCALL; my $tmpl =
Template->new({INTERPOLATE => 1}); $tmpl->process("test.tmpl",\%vars)
|| die($tmpl->error()); #-----------
end The idea is to delegate
to the template code to call the method in the SKdb package. This call will
always return a ref to an array of hashes, and the template code looks like
this: # test.tmpl
---------- [% FOREACH a = LARTS(<some
parameters>) %] <print out some hash keys, like
:> [% a.TITLE %] [% END
%] On machine A the code works
as intended, on machine B it does not. On B, TT executes the call to the method
correctly, and the method receieves the parameters as it should, but it �looks
like� TT is not able to iterate over the array ref from the method call,
although the FOREACH loop is executed the correct number of times. To verify
this, I let the template write out the �a� object (which should be a hash)
rather than dereferencing the hash attributes. On machine B (where the
problem is), I then get this output: a =
ARRAY(0x84d4d3c) a = 1 a = 3 while on A I correctly get
this a =
HASH(0x83be794) a =
HASH(0x83c9244) a =
HASH(0x83c9328) So what goes on? The number
of iterations is correct (3) on B, but the returned object in each iteration is
completely messed up. I can sort of work around the
problem on B my moving the method call in to the Perl code in test.pl, but
that�s not what I want. That is, if I do $vars{LARTS} = SKdb::dbCALL(<some
parameters>); and have the template look
like this: [% FOREACH a = LARTS
%] <print out some hash keys, like
:> [% a.TITLE %] [% END
%] things work properly on B
too! I�m desperately looking for
advice on how I could debug this further. I suspect that the problem may be due
to differences/bugs in some external backend modules used by TT. Maybe someone
knowing the TT internals have some advice on where to look? I do not have
operating control of the Perl installation on B, since it�s provided by an ISP,
but I�am of course able to check out the Perl installation
there. I�m grateful for any advice on how to proceed.
Regards, Steinar Kj�rnsr�d [EMAIL PROTECTED] |
- Re: [Templates] Inconsistent TT behaviour between two di... Steinar Kj�rnsr�d
