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

[cgiapp] RE: :App, CGI::Session and CGI::Simple


While you are correct that the -better- solution is to rely on can(),
this still isn't a very good solution. There's two problems I can see
off the bat:

1) You will want to do that kind of checking when you are handed the
object in your constructor. So, you'll have to compile a list of methods
the object will need to handle. Now, this is a good thing, from a
documentation standpoint, but it's not what you suggested.

2) My CGI::Application children have a param() method (inherited from
C::A). Now, if I provide a cookie() method (say, to handle my
site-specific cookies), I now pass your interface requirements. But, I'm
positive I won't be doing what you want.

The -real- solution is not available until Perl6 when Roles are
introduced into the language. At that point, you will be able to ask "if
($class does CGI)" and be done with it.

-----Original Message-----
From: Ron Savage [mailto:suppressed 
Sent: Monday, April 26, 2004 10:36 PM
To: Perl - CGI::Application
Subject: CGI::App, CGI::Session and CGI::Simple

Hi Folks

Normally your app using CGI::Session would look like:

#!/usr/bin/perl
use DBIx::Admin::Application;
DBIx::Admin::Application -> new() -> run();

However, if your try:
#!/usr/bin/perl
use CGI::Simple;
use DBIx::Admin::Application;
DBIx::Admin::Application -> new(QUERY => CGI::Simple -> new() ) -> 
run();

you'll find it does not work. This is due to a bug in CGI::Session.
V 3.94 has this on line 168:
	if ( $arg->isa('CGI') ) {...
which means only a CGI-derived object can be used.
To use CGI::Simple you could - but shouldn't - try:
        if ( $arg->isa('CGI') || $arg->isa('CGI::Simple') ) {...
Obviously it's ridiculous to list all possible class names here. The 
real solution is to use something like:
		if ($arg -> can('cookie') ){ call cookie }
		elsif ($arg -> can('param') ){ call param }
I have logged a bug report via rt.cpan.org on this matter.
-- 
Ron Savage, suppressed on 27/04/2004. Room EF 312
Deakin University, 221 Burwood Highway, Burwood, VIC 3125, Australia
Phone: +61-3-9251 7067, Fax: +61-3-9251 7604
http://www.deakin.edu.au/~rsav



---------------------------------------------------------------------
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.