vroom has asked for the wisdom of the Perl Monks concerning the following question:
My only problem is that I am trying to implement a error_mode for unspecified run_modes as specified in the docs by adding a handler to AUTOLOAD. However it only runs on &rm=AUTOLOAD and not unspecified runmodes like &rm=blah. I'm probably forgetting something obvious but it looks right. Here's the slimmed down code.
package LocalSite::InquiryQueryApp; use LocalSite::InquiryUtils; use base 'CGI::Application'; use strict; sub setup{ my $self=shift; $self->start_mode('query'); $self->mode_param('rm'); $self->run_modes( 'query'=>\&query_mode, 'display'=>\&display_mode, "AUTOLOAD"=>\&error_mode ); #get our database connection $self->param('dbh'=>getDbConnection); } sub query_mode{ my $self=shift; my $query=$self->query(); my $str="<HTML><BODY>Query Mode</BODY></HTML>"; return $str; } sub error_mode{ my $self=shift; my $rm=shift; my $str="<HTML><BODY>Error: you have chosen an invalid runmode</BODY +></HTML>"; return $str; } sub display_mode{ my $self=shift; my $query=$self->query(); my $str="<HTML><BODY>Display Mode</BODY></HTML>"; return $str; } sub teardown{ my $self=shift; $self->param('dbh')->disconnect(); } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI::Application Question
by rob_au (Abbot) on Aug 22, 2001 at 18:54 UTC |