Skip Menu |

This queue is for tickets about the CGI-Application CPAN distribution.

Report information
The Basics
Id: 39631
Status: resolved
Priority: 0/
Queue: CGI-Application

People
Owner: MARKSTOS [...] cpan.org
Requestors: rhesa [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Unimportant
Broken in:
  • 4.06
  • 4.10
Fixed in: (no value)



Subject: default "start" runmode set too late to override through an init callback
By default, CGI::Application sets a default "start" runmode in setup(). This means it's impossible to replace the "start" runmode through an "init" callback, without also overriding setup(). I suggest moving the default into the initialization of the run_modes datastructure. That way it'll be set when run_modes() is first called, and can still be overridden later on. Attached is a test file demonstrating the issue, and a patch to fix it.
Subject: start_issue.diff
--- lib/CGI/Application.pm 2008-08-10 17:34:30.000000000 +0200 +++ lib/CGI/Application.pm.new 2008-09-26 17:32:30.000000000 +0200 @@ -257,9 +257,7 @@ sub setup { my $c = shift; - $c->run_modes( - 'start' => 'dump_html', - ); + # Nothing to setup, yet! } @@ -491,7 +489,7 @@ my (@data) = (@_); # First use? Create new __RUN_MODES! - $c->{__RUN_MODES} = {} unless (exists($c->{__RUN_MODES})); + $c->{__RUN_MODES} = { 'start' => 'dump_html' } unless (exists($c->{__RUN_MODES})); my $rr_m = $c->{__RUN_MODES};
Subject: default_runmode.t
use strict; use warnings; use Test::More tests => 1; $ENV{'CGI_APP_RETURN_ONLY'} = 1; # don't print { package WithStartIssue; use base 'CGI::Application'; # register custom "start" run mode. # this is what CAP::AutoRunmode and CAP::RunmodeDeclare do. __PACKAGE__->add_callback('init' => sub { shift->run_modes('start' => 'my_start'); } ); sub my_start { return 'my start' } # don't output a header sub cgiapp_prerun { shift->header_type('none'); } } my $issue = WithStartIssue->new; my $out = $issue->run; is $out, 'my start';
Released today. Thanks, Rhesa. Mark