develooper Front page | perl.perl5.porters | Postings from March 2007

Re: [perl #41572] Subclassing CGI::Pretty dies in ->new

Thread Previous | Thread Next
From:
Wolfgang Laun
Date:
March 8, 2007 06:43
Subject:
Re: [perl #41572] Subclassing CGI::Pretty dies in ->new
Message ID:
45F01B76.5050101@thalesgroup.com
On Thu, 22 Feb 2007 03:41:20 Jeremy wrote:

> If I create a module Jeremy::CGI that subclasses CGI::Pretty and call
> Jeremy::CGI->new then Perl dies with 
> 
> Undefined subroutine Jeremy::CGI::delete
> at /data/www-jeremy/cgi-bin/cgi-jeremy line 9
> 
> Line 9 is the call to Jeremy::CGI->new 

I have traced this into CGI::_compile where some complex logic based on 
AUTOLOAD compiles a called method from some string value. It seems that 
any class sub- or sub-sub-classing CGI has to have a scalar

   $MyCgiSubclass::AutoloadClass = 'CGI';

as can be seen in CGI::Pretty.

It's not a good idea to re-use the base class name (CGI) as the name of 
a sub-sub-class. So, let's assume we have changed Jeremy::CGI to 
Jeremy::JCGI. Then, Jeremy's problem can be solved by adding this line 
to Jeremy::JCGI

   $Jeremy::JCGI::AutoloadClass = 'CGI';

If I'm correct, then CGI.pm's pod is lacking some documentation about 
this and possibly also for $CGI::DefaultClass, which is also set by 
CGI::Pretty.

And there is, of course, the question why a subclass has to be burdened 
with this unusual incantation, but I'm not prepared to answer this or 
even to propose a patch for CGI::_compile.

Kind regards
Wolfgang



Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About