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?


In reply to Changes in Latest Version of CGI::Application (4.02) by jgallagher

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.