Hi all,
here is another take on one of my favourite topics, the automatic discovery of run modes.
Basically, I want to have CGI::App to look at my application instance and call a method of the
same name as the requested run-mode. Because of the security problem inherent in this approach,
some care has to be taken.
One way to mark the appropriate subroutines as run modes is to use subroutine attributes.
I implemented that in the CGI::App plugin AutoRunmode:
package MyApp;
use base 'CGI::Application';
use CGI::Application::Plugin::AutoRunmode
qw [ cgiapp_prerun]; sub my_run_mode : Runmode {
# do something here
}This works well, but now I have another idea, using a delegate object that implements all the run-modes.
I got this idea from working with Objective-C/Cocoa, which makes use of delegation (rather than inheritance)
a lot.
So, you can set up a delegate object, all of which methods are run-modes.
It is important that it has not other methods, since these methods will be directly accessible via the web (they are all considered run modes).
I have extended the AutoRunmode plugin to support this new approach as well.
Have a look if you want:
Docs: http://perl-pad.sourceforge.net/cgiapp/AutoRunmode.html
Module: http://perl-pad.sourceforge.net/cgiapp/CGI-Application-Plugin- AutoRunmode-0.03.tar.gz
Assuming there are no grave mistakes, the module is on its way to CPAN.
Thilo
PS:
The plugin has support for the Callbacks extension, which is not on CPAN.
I think the latest version is here:
http://cees.crtconsulting.ca/perl/modules/CGI-Application-Callbacks -0.01/
Two questions:
1) What happened to the callback idea?
2) There seems to be a bug in Callbacks, as it tries to croak without loading the Carp module first.
--------------------------------------------------------------------- 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]
