I just got bit by a change in the latest version of CGI::Application that appears to be undocumented. I'm wondering if I'm doing things incorrectly or if I should send the author a bug report.
The problem, at first glance, is that my application will only return the default run mode. I am setting mode_param() in cgiapp_init to something other than rm. Looking back in the docs, I see "mode_param is generally called in the setup() method," which leads me to believe my calling it in cgiapp_init should be valid. Otherwise, I would have to make the same mode_param call in setup of all the subclasses of my custom base class.
The problem is that, prior to 4.02, the CGI::Application new() method looked like so:
sub new {
# ... miscellany
# Create our object!
my $self = {};
bless($self, $class);
### SET UP DEFAULT VALUES ###
#
# We set them up here and not in the setup() because a subclass
# which implements setup() still needs default values!
$self->header_type('header');
$self->mode_param('rm');
$self->start_mode('start');
# ... remainder of constructor,
# including init and setup calls
}
Now those defaults have been moved until just before
setup(), the final call, meaning they overwrite anything set in the init phase:
sub new {
# ... miscellany
# Call cgiapp_init() method, which may be implemented in the sub-c
+lass.
# Pass all constructor args forward. This will allow flexible usa
+ge
# down the line.
$self->call_hook('init', @args);
### SET UP DEFAULT VALUES ###
#
# We set them up here and not in the setup() because a subclass
# which implements setup() still needs default values!
$self->header_type('header');
$self->mode_param('rm');
$self->start_mode('start') unless defined $self->start_mode;
# Call setup() method, which should be implemented in the sub-clas
+s!
$self->setup();
return $self;
}
I suppose the purpose of this post is twofold. One, don't get caught like this if you upgrade CGI::Application. :-) Two, am I doing the wrong thing by calling mode_param from a parent class cgiapp_init?