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

[cgiapp] Idea for Super class of CGI::Application


So I have to manage several similar web sites.  I came up with this to
reduce the time it takes me to write/configure them.
The modules I want to use I place in
@CGI::Application::FrameWork::Config::Modules array in the CGI scripts
BEGIN statement.  At the beginning of the modules I register the
module's run modes.

If CGI::Applications where written to be used in this manner many
written by different authors could be easily combine.  Some manners that
would need to be laid out:
Modules of this type that are published can not use the start mode.
All run modes start with the name of your module.

If these manners are adhered to then one could quickly piece together
several modules into one CGI App.

What do you think?

<cgi script>
BEGIN {
    use CGI::Application::FrameWork::Config;
    @CGI::Application::FrameWork::Config::Modules = qw (Navigation);
}

use CGI::Application::FrameWork;

my $app = CGI::Application::FrameWork->new();
$app->run();
</cgi script>

<Super Class>
package CGI::Application::FrameWork;
use base qw (CGI::Application);
use base @CGI::Application::FrameWork::App::Config::Modules;
use strict;

sub setup {
    my $self = shift;
    
    $self->run_modes(\%CGI::Application::FrameWork::Config::Run_Modes);
    $self->start_mode($CGI::Application::FrameWork::Config::Start_Mode);
    $self->mode_param('rm');
}
1;
</Super Class>

<Super Class Config>
package CGI::Application::FrameWork::Config;
use strict;

our %Run_Modes;
our %Start_Modes;
our @Modules;

1;
</Super Class Config>

<Example Module>
package Navigation;
use strict;
use CGI::Application::FrameWork::Config;
for (qw(Navigation_top Navigation_right_ Navigation_nav
Navigation_top_nav Navigation_left_nav Navigation_bottom_nav )) {
    $CGI::Application::FrameWork::Config::Run_Modes{$_} = $_;
}
$CGI::Application::FrameWork::Config::Start_Mode = 'top';

sub top {
    my $self = shift;
    # Get the CGI.pm query object
    my $q = $self->query();
    my $output = undef;
    ...
    return $output;
}

sub Navigation_right_nav {
    ...
}

sub Navigation_left_nav {
    ...
}

sub Navigation_top_nav {
    ...
}

sub Navigation_bottom_nav {
    ...
}

sub Navigation_home {
    ...
}
1;
</Example Module>

Jay Flowers
Integic
Health Care



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
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.