Hi Tim --
> I'm trying to move runmode subs, which I'm going to call
> 'actions', into
> their own class/file/package.
Why do that?
If you're interested in the Model-View-Controller (MVC) design pattern,
think of CGI::Application as the "Controller". As such, any code which
interacts with the CGI request or form data should be in your Application
module. That would include your run-mode methods.
Your "Model" (the back-end business logic) could easily be stored in a
separate module and used by your Application module. Consider the
following:
package MyApplication;
use base 'CGI::Application';
# Use your "Model"
use BusinessLogic;
sub setup {
my $self = shift;
$self->run_modes(
'mode1' => \&add_user,
'mode2' => \&rm_user,
);
}
sub add_user {
my $self = shift;
my $username = $self->query->param('username');
BusinessLogic->add_user($username);
return "User $username was successfully added!";
}
sub rm_user {
my $self = shift;
my $username = $self->query->param('username');
BusinessLogic->rm_user($username);
return "User $username was successfully removed!";
}
This, IMHO, is a good example of the M-V-C pattern, implemented using
CGI::Application.
-Jesse-
--
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Jesse Erlbaum ....................... CTO
[EMAIL PROTECTED] ............. Vanguard Media
v: 212.242.5317 x115 ...... New York City
+-+-+-+-+-+- http://www.vm.com/ +-+-+-+-+-+-+
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]