Hello,
I may be going about this wrong and hoped more experienced eyes
could look at things. I want to create a base class for all CGI
applications on my site. Individual apps would use the base class
which would transparently add authentication and other functions.
More code is below my signature. My question concerns
automatically loading the site wide run modes (currently just
'login'). I am adding site wide run modes by overriding the
run_modes() method.
# Silently add site level run modes here.
sub run_modes {
my $self = shift;
my $run_modes = shift;
return $self->SUPER::run_modes( [ 'login', @$run_modes ] );
}
Is there any gotcha I need to worry about or is this an
acceptable practice? (Note: I'm using C::A 4.0_2)
TIA,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
package Site::SunValleyWebSite;
use base 'CGI::Application';
use CGI::Application::Plugin::Session;
sub cgiapp_prerun {
my $self = shift;
# Redirect to login, if necessary
$self->prerun_mode( 'login' ) unless
$self->session->param( '~logged-in' );
}
# Site run mode
sub login {
my $self = shift;
my $template = $self->load_tmpl(
'c:/1/clarkson/cgi-bin/Site/templates/login.tmpl',
);
return $template->output();
}
# Silently add site level run modes here.
sub run_modes {
my $self = shift;
my $run_modes = shift;
return $self->SUPER::run_modes( [ 'login', @$run_modes ] );
}
1;
package Editor::ArticleEditor;
use base 'Site::SunValleyWebSite';
sub setup {
my $self = shift;
$self->start_mode( 'home' );
$self->mode_param( 'rm' );
$self->run_modes(
[
qw(
editor_home
load_article
update_changes
commit_changes
) ]
);
}
sub editor_home {
my $self = shift;
my $template = $self->load_tmpl(
'/templates/editor_home.tmpl',
path => 'c:/1/clarkson/cgi-bin/editor/',
associate => $self->query(),
die_on_bad_param => 0,
);
return $template->output();
}
1;
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]