in reply to Re: DBI handle destroyed during CGI::Application setup
in thread DBI handle destroyed during CGI::Application setup

I have implemented a teardown routine; but not calling it is not the cause of my error.

And I still don't understand how your sub setup executes without error -- you are creating a DBI handle within your call to $self->param just as I was -- and I got a DBI error out of that.

I also note that you have also made the change from

$self->run_modes( 'mode1' => 'showform', 'mode2' => 'showlist' );
to
$self->run_modes( 'mode1' => \&showform, 'mode2' => \&showlist );
Is the original documentation inaccurate? After some skull sweat I figured out the answer myself, and I'm glad to see that you have it correctly on your page. I will peruse your node with a magnifying glass to see how many other 'gotcha's there are -- thanks for your contribution.

--t. alex

"Excellent. Release the hounds." -- Monty Burns.

Replies are listed 'Best First'.
Re: Re: Re: DBI handle destroyed during CGI::Application setup
by rob_au (Abbot) on Jan 07, 2002 at 04:48 UTC
    I'll post some sample code that makes uses a DBI handle within a param object for illustration - It might be worthwhile your putting a more complete segment of your code up on your scratchpad for me to have a look through because the implementation of the disconnect method on the DBI handle within the teardown method should correct your errors.

    Some sample CGI::Application code using DBI handles follows - Note that my usage of the param function differs slightly as I prefer to define my parameters through the instance object of my CGI::Application class.

      Perl still isn't happy with your hash in the call to set up run_modes in this statement:
      $self->run_modes ({ 'logon' => 'LogonPage', 'vlogon' => 'VerifyLogon', 'menu' => 'MenuPage', 'todo' => 'ToDoPage' }); # your run_modes argument was not explicitly a hash - the br +aces correct this
      I still get
      Can't use string ("LogonPage") as a subroutine ref while "strict refs" + in use at /usr/local/lib/perl5/site_perl/5.6.0/CGI/Application.pm li +ne 90.
      Changing back to
      $self->run_modes ( 'logon' => \&LogonPage, 'vlogon' => \&VerifyLogon, 'menu' => \&MenuPage, 'todo' => \&ToDoPage ); # your run_modes argument was not explicitly a hash - the bra +ces correct this
      makes Perl happy .. no errors, and the first page comes up fine.

      --t. alex

      "Excellent. Release the hounds." -- Monty Burns.

        You have to upgrade. Prior to version 1.3, CGI::Application only allowed subrefs (\&my_mode) -- not name-based references ('my_mode').

        Name-based referenced were added to improve CGI::Application's sub-classing functionality. Modern versions allow both sub-refs and name-based refs.

        The best answers to questions related to CGI::Application can be found on the official mailing list. To subscribe, send email to:

           cgiapp-subscribe@lists.vm.com

        An archive of the list can be found at:

           http://www.mail-archive.com/cgiapp%40lists.vm.com/