Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: CGI::Application and inheritance

by Belgarion (Chaplain)
on May 19, 2004 at 20:22 UTC ( [id://354740]=note: print w/replies, xml ) Need Help??


in reply to CGI::Application and inheritance

The way I usually do this sort of thing is place the following in the base class:

package BaseClass; use base 'CGI::Application'; sub cgiapp_init { my $self = shift; $self->run_modes('mode1_common' => \&mode1_common, 'mode2_common' => \&mode2_common); }

Then in the derived class I have the standard:

package DerivedClass; use base 'BaseClass'; sub setup { my $self = shift; $self->start_mode('start'); $self->run_modes([qw(derived_mode1 derived_mode2)]); }

As the CGI::Application documentation for cgiapp_init states:

If implemented, this method is called automatically right before the setup() method is called. This method provides an optional initialization hook, which improves the object-oriented character- istics of CGI::Application. The cgiapp_init() method receives, as its parameters, all the arguments which were sent to the new() method.

Replies are listed 'Best First'.
Re: Re: CGI::Application and inheritance
by geektron (Curate) on May 19, 2004 at 20:28 UTC
    that's the key. i missed that in the docs.

    i've been using cgiapp_prerun .. but not cgiapp_init

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://354740]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2025-07-11 15:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.