Hi list,

I'm trying to get the concept of creating a super class for my application and understand what elements need to be included in the base application module.

Let's say I want to create a web app called MyApp. My Directory structure looks like this ...

/MyApp
        Base.pm
        User.pm
        Inventory.pm
        Other.pm

My Base class would be

package MyApp::Base.pm
use base 'CGI::Application';

sub cgiapp_init {...};
sub cgiapp_prerun {...};
sub _some_common_code {...};

1;

Then all of my other packages will contain the run modes for that module and can call methods from the base class as long as they are setup as follows

package MyApp::User.pm;
use base 'MyApp::Base';

sub cgiapp_init {
        my $self = shift;
        $self->start_mode( 'display_users' );
        $self->tmpl_path( set_template_path_here );
        $self->run_modes( qw/ display_users display_user_form edit_user /);
        ... module specific init items here
}

sub display_users {...}
sub display_user_form {...}
sub edit_user {...}
1;

Am I understanding the layout correctly?

Ed Pigg

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.erlbaum.net/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to