Charles K. Clarkson wrote:
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)
I don't think you need to be that fancy. The standard run_modes() function
*adds* the supplied arguments to its internal storage.
So you can add the 'login' run_mode in your super class, and simply add the
custom run modes in your class:
package CA::Base;
use base qw/CGI::Application/;
sub cgiapp_init {
my $self = shift;
$self->run_modes([ 'login' ]);
}
1;
package CA::MyApp;
use base qw/CA::Base/;
sub setup {
my $self = shift;
$self->run_modes([ qw/foo bar/ ]);
}
1;
Now every package that inherits from CA::Base has a login run mode. No hassle.
HTH,
Rhesa
---------------------------------------------------------------------
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]