[cgiapp] New Plugin: RunmodeDeclare

Mark Stosberg mark at summersault.com
Sat Sep 27 00:50:15 EDT 2008


As Rhesa proposed, he has followed through and released a plugin to add the
Devel::Declare / Method::Signatures magic to CGI::Application:

http://search.cpan.org/perldoc?CGI::Application::Plugin::RunmodeDeclare

Used in combination with Method::Signatures, this approach can noticably shorten
the amount of code you need to write, shrinking your 'setup()' routine and reducing
"busy work" of writing "my $self = shift;" and unpacking other parameters. 

For a comparison, I refactored the simple "widget" example from the
CGI::Application documentation. The result was about 15% fewer lines of code.

Take a look for yourself at the RunmodeDeclare plugin

My single point of feedback is the order in which the plugin looks for run mode
values. 

It looks first the query object and then in the object's param() method.  

I would reverse this order for security.  If I intentionally pass something
through $self->param(), I don't want the public to be able to override that
through the query object. 

If I intend for the query object be an option here, I can explicity *not* pass
the value through param(), so it falls through to the query object. 

    Mark

-- 
http://mark.stosberg.com/





More information about the cgiapp mailing list