Also note that you can already do the following in CGI::App to access runmodes defined in other packages:
sub setup{ my ($self) = @_; $self->run_modes( 'start' => 'MyRunModes::blah' ); }
To spare me digging into the code, what does the above actually do?
Sorry for the brevity of the example.
For above case you would have to have a module with a subroutine blah that
implements the run-mode.
package MyRunModes; sub blah{ my ($app) = @_; # implement the run mode here (as usual) my $p = $app->param('foo'); return 'some html'; }
is 'MyRunModes::blah', purely a set of runmodes that don't do anything unless they are loaded into a CGI::App module?
No, it is just a single runmode. And you would have to load the module yourself before trying to use it.
Is it a CGI::App module?
No, it is something you have to write yourself, and it does not have to be a CGI::App subclass.
I just wanted to show that if you want to break out the implementation of the run mode into different modules,
you can already do this in CGI::App.
My AutoRunmode plugin is just about discovering those run modes, so that you do not have to manually register them.
Another (probably better) way to do the same thing would be this pattern (using multiple inheritance):
package MyTestApp; use base qw[ CGI::Application MyRunModes ];
sub setup{
my ($self) = @_;
$self->run_modes( 'start' => 'blah' ); # this works because MyTestApp inherited "blah" from MyRunModes
}
Finally I would like to point out that these run mode subroutines (no matter where you place them in your module hierarchy) should in my opinion be small wrappers around some back-end modules that do the real work.
CGI::App is just the controller in the MCV framework, the "business logic" should be in other modules (not in the CGI::App subclass) where they can also be accessed outside of the web context.
Thilo
--------------------------------------------------------------------- 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]
