Skip Menu |

This queue is for tickets about the Template-Plugin-Class CPAN distribution.

Report information
The Basics
Id: 6027
Status: resolved
Priority: 0/
Queue: Template-Plugin-Class

People
Owner: Nobody in particular
Requestors: tom@eborcom.com (no email address)
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: Template::Plugin::Class should report attempts to call non-existant methods
Hi, We're using Template::Plugin::Class 0.12 and finding it very useful. Yesterday we encountered a problem whereby calling a non-existant method didn't produce a helpful error message. I have attached a small patch that deals with this. Tom
--- Template/Plugin/Class.pm.was Tue Jan 13 13:58:39 2004 +++ Template/Plugin/Class.pm Thu Apr 15 18:02:27 2004 @@ -27,11 +27,13 @@ package Template::Plugin::Class::Proxy; use vars qw( $AUTOLOAD ); +use Carp qw(carp); sub AUTOLOAD { my $self = shift; my $class = ref $self; my ($method) = ($AUTOLOAD =~ /^$class\::(.*)/); + $$self->can($method) or carp "$$self cannot $method"; $$self->$method(@_); }
[guest - Thu Apr 15 13:09:20 2004]: Show quoted text
> Hi, > > We're using Template::Plugin::Class 0.12 and finding it very useful. > Yesterday we encountered a problem whereby calling a non-existant > method didn't produce a helpful error message. I have attached a > small patch that deals with this. > > Tom
Thanks, but sadly this isn't the right place to fix this - the issue is that TT itself is hiding the method call failure if it looks like a regular method call. Consider: # file Foo.pm package Foo; use base qw( Class::Accessor ); # for a new sub foo {} 1; # file demo use Template; use Foo; my $foo = Foo->new; Template->new->process('template', { foo => $foo }); # file template [% USE another_foo = Class('Foo') %] This is no error: [% foo.bar %] So neither can this be: [% another_foo.new.bar %] Sorry about this, but it's actually intended behaviour for Template Toolkit. -- Richard Clamp <richardc@unixbeard.net>