[cgiapp] New Plugin: RunmodeDeclare

Richard Jones ra.jones at dpw.clara.co.uk
Tue Oct 21 06:32:11 EDT 2008


Rhesa Rozendaal wrote:

> Version 0.03 is on CPAN now, and adds this feature:
> 
>   use CGI::Application::Plugin::RunmodeDeclare invocant => '$c';
> 
>   runmode foo { $c->bar }
> 
> It also incorporates the suggestion by Mark and Michael to first default 
> to $app->param, then to $query->param.

So, having had chance to have a play with it, I've run into a couple of 
problems. First, all subclasses need to 'use 
CGI::Application::Plugin::RunmodeDeclare' - it is not inherited from the 
superclass as are all other CAP's. Attempts to run against a subclass 
without the 'use CAP::RunmodeDeclare' causes a syntax error. Not a 
problem as such, but seems odd.

Second, the superclass startmode seems to override the subclass 
startmode. With a setup where My::WebApp::Foo subclass inherits from 
My::WebApp superclass, a request to /myapp.cgi that maps to 
My::WebApp::Foo should display the subclass startmode template, but it 
doesn't - it loads the template defined in the superclass startmode 
instead. Specifying the rm eg /myapp.cgi?rm=rm1 does work as expected 
though - loads My::WebApp::Foo::rm1 template.

I know I could specify the required rm in all requests 
(myapp.cgi?rm=start), but I'm using Dispatch where :app and :app/:rm are 
used in the dispatch table, and this works as documented with 
CAP::AutoRunmode - ie the subclass StartRunmode 'wins'.
--
Richard Jones



More information about the cgiapp mailing list