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

Re: [cgiapp] cgi_minimal compatible?


> b) Add the header() function to CGI::Minimal.
> Since this is Perl, you can just add methods to classes at runtime:

Thanks for the example. (It worked!). I put it in my wrapper class (which
inherits CGI::Minimal) and it worked too. I don't understand why the method
name had to be fully qualified like that. I thought if I create a class and
it uses another class as its base, then any methods in my class or the base
class would be accessible using my class name. (I wonder if CGI::Minimal had
its name hardcoded somewhere so it couldn't be extended like this?)

Anyway, if anyone else wants to use CGI::Minimal, what I have is:

cgi script:
================================================
#! /usr/bin/perl -w
use strict;

use WebApp;
my $webapp = WebApp->new();
$webapp->run();

exit;
==================================================

Web Application package:
==================================================
# In "WebApp.pm"...
package WebApp;
use base 'CGI::Application';

sub cgiapp_get_query() {

        my $self = shift;

        # Include CGI.pm and related modules
        require "myQuery.pm";

        # Get the query object
        my $q =  myQuery->new();

        return $q;

}

sub setup {
... normal stuff here from the sample article ...
}

1;

==================================================

And my wrapper to CGI::Minimal

==================================================
# In "myQuery.pm"...
package myQuery;
use base 'CGI::Minimal';


sub CGI::Minimal::header {

  my $self = shift;

 my $x = 'http header string';

 return $x;

}


1;
====================================================



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