[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] Re: critical bug in 'import' of CGI::App 3.21 (test case available)


William McKee wrote:

>On Thu, Feb 12, 2004 at 04:24:12PM +0000, Steve Hay wrote:
>  
>
>>The only issue being created that doesn't already exist which I can 
>>think of is the one that I alluded to with my patch, namely where people 
>>inherit from three or more classes.  They could code a Foo class such 
>>that @ISA = qw(CGI::Application Foo Exporter) will work under C::A 3.1 
>>(i.e. Foo's import() calls Exporter's), but now, because of C::A 
>>introducing an import() routine, that would break.
>>
>>Perhaps an "Incompatible Changes" section should be introduced into the 
>>README or POD documentation describing this possible scenario.
>>    
>>
>
>I happened to have left off reading Damian's _Object Oriented Perl_ at
>just this section. If anyone has the book, they may want to read through
>section 6.2.4 - The SUPER pseudo-package (p. 183-184).
>
>Besides being a good description of the problem at hand, it discusses a
>solution for calling all of the import() methods in all of the inherited
>classes. I'm not familiar with using Exporter (as I do not use it
>regularly) so this solution may not be at all desirable.
>
>Perhaps using SUPER instead of short-circuiting the inheritance tree
>would be a solution to the above problem that Steve described. If Foo
>did not have an import() function, wouldn't it get passed up to
>Exporter? Perhaps Steve's code could be modified to the following:
>
>  goto SUPER::import if $class->isa('Exporter');
>
I don't think you can use SUPER:: in that way; you can only use it in 
method calls.  goto() would probably just complain that SUPER::import 
doesn't exist.  (And you meant "goto &SUPER::import", not "goto 
SUPER::import", didn't you ;)

Anyway, I don't think SUPER:: is what you want here -- 
$class->SUPER::method() starts the search for a superclass method() in 
the *current package*, not the original invocant's package.  So if we're 
in CGI::Application::import then that would start the search for a 
superclass import() in CGI::Application, and wouldn't find anything 
because CGI::Application itself has no superclasses.

Using SUPER:: to have all superclass methods called only works in a 
single-inheritance hierarchy otherwise the other branches get missed.

In this case, we want to backtrack past the current package, back to the 
TestImport package (the original invocant) and look for another import() 
method from there -- i.e. to find another one in some other branch of 
it's multiple inheritance tree.

Damian Conway's excellent NEXT module comes to the rescue there, doing 
exactly that, but it is only a core module from Perl 5.8.0 onwards...

- Steve

>
>It seems to me that this multiple-inheritance problem goes to show why
>Sam is not keen on using the mix-in pattern for adding new functionality
>to C::A (ala C::A::ValidateRM and C::A::Session). Am I following these
>issues correctly (I'm new to the whole multiple-inheritance model
>myself)?
>
>
>Thanks,
>William
>
>  
>




------------------------------------------------
Radan Computational Ltd.

The information contained in this message and any files transmitted with it are confidential and intended for the addressee(s) only.  If you have received this message in error or there are any problems, please notify the sender immediately.  The unauthorized use, disclosure, copying or alteration of this message is strictly forbidden.  Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of Radan Computational Ltd.  The recipient(s) of this message should check it and any attached files for viruses: Radan Computational will accept no liability for any damage caused by any virus transmitted by this email.


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.