On Tue, Jul 24, 2001 at 10:04:18PM -0700, Craig Barratt wrote:
: casey> I don't think this has been applied, at least I haven't
: casey> seen it in the change logs. This would be *very* handy
: casey> for Tangram objects. Tangram and TT should be a happy
: casey> couple.
: casey>
: casey> http://www.template-toolkit.org/pipermail/templates/2001-June/-001047.html
:
: casey> I have a situation where I'm trying to access class member data and TT
: casey> blows up with an 'undef error' because it was only able to try to
: casey> invoke the class method. Here is a patch under duress, probably not
: casey> perfect but fixes the problem for me.
:
: I don't understand this issue and patch. TT2 can access members of
: blessed references. In the case where DEBUG is set, you will get an
: undef error if you try to access a class member whose value is undef.
: But DEBUG is somewhat broken and needs to be reworked (should be on
: the v3 list).
:
: If DEBUG is not set then I don't see what your patch does differently
: to the default behavior. It would be helpful if you could post a
: short example highlighting the difference.
I'm sorry, I should have specified. I was running under debug but,
I'll have to go back to my example and see if it would still be broken
without debug set.
The object was simple:
package foo;
sub new {
my( $class, %args ) = @_;
return bless \%args, $class;
}
And then I simply did this:
$tt->process(
$file,
{
foo => foo->new( foo => 'bar', baz => 'bang' );
}
);
And, when trying to access [% foo.baz %] it was only checking for
method calls because 'foo' was blessed to a package. And obviously
you don't go around breaking interfaces by accessing member data so I
understood why this wasn't (seemingly, at least) as flexible as I'd
like.
In any case, I'll be sitting down with Andy sometime tomorrow and
hashing this (and quite a few other things) out.
Casey West
--
If you don't double-click me, I can't do anything.
-- John Aniston, on how computers have taken over his life