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

Re: [cgiapp] Sub classing CGI::App


"Jamie Krasnoo" <suppressed> wrote on 11/17/2006 02:15:01 PM:
> Ok I have a quick question on setup when you're sub classing CGI::App.
> 
> If I want to be able to specify standard run modes, and mode_params
> without having to overload the setup function each time I use it. How
> does that work?

I do this with hooks ...

package SuperApp;

use strict;
use warnings;

use base 'CGI::Application';

SuperApp->add_callback('init', \&sa_hook_init);

sub sa_hook_init {
        my $self = shift;
        my @args = shift;
 
        # supply a global error handler
        $self->run_modes(
                'error' => 'do_error'
        );
 
        # set the default error handler
        $self->error_mode('do_error');
}

Then, in the sub modules:

use base 'SuperApp';

instead of

use base 'CGI::Application';

Todd Ross

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