On 2003-10-17, Clint Moore <suppressed> wrote:
>
> Several months ago, I wrote about how I was using pluggable mini
> applications with CGI::App in an application I was developing. Since
> then i have decided to write, if for no one besides myself, a module to
> handle this. I welcome any comments and suggestions.
>
> There is one glaring issue that I need to figure out an elegant
> solution for and that is how to get a form to the main application from
> a plugin. At the moment I am using a terribly ugly hack (see
> 'plugin_button' below) to demonstrate the module. Any comments on this
> are certainly welcome.
I like that with your solution could just "drop in" in a module and it
could work.
I'll add to the conversation a couple of techniques I've used to
implement "plug-ins" in CGI::App.
The first method I believe is known as a "mix-in method". This is what
CGI::Application::ValidateRM does:
Just "use CGI::Application::ValidateRM" and voila, you have a a couple
of new methods available.
The second method I'ved used was less flexible. It was to simply create a
sub-class, add some run modes, and then call the setup routine in the
SUPER class to make all the original run modes available.
Here's what a code snippet for that looked like:
package Cascade::BookSearch;
use base Cascade;
sub setup {
my $self = shift;
$self->run_modes([qw/book_search/]);
return $self->SUPER::setup();
}
sub book_search {
my $self = shift;
# ... beefy code goes here...
}
The limitation above is that you are tied to specific super-class.
There's probably an easy way to address that, but I'm not seeing it
now.
I think I find the "mix-in" method the most intuitive way to handle
plug-in methods generically.
Mark
--
http://mark.stosberg.com/
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/suppressed/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
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.