Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
And another one, if I may . . .

The code below are the relevant excerpts from the module we're building here. But this one is confusing me. This database conection was working for me before I commented it out of cgiapp_init() and tried to offload the work into a new dbh() routine.

The errors read: "Error executing class callback in init stage: Can't call method "config_file" on an undefined value at /home/hesco/anmc/sb/Registration/Registration/lib/Registration/WWW/ line 114." Line 114 is a part of the dbh() routine and reads: $self->config_file('/var/lib/cf/tbd/regform/Registration.ini');

So what here is the undefined value? Isn't $self defined? Why wouldn't it be passed from cgiapp_init? If not $self, then how is it that a hard coded path would be undefined?

I don't get it?

-- Hugh

package Registration::WWW::RegForm; use warnings; use strict; use diagnostics; use base 'CGI::Application'; use CGI::Application::Plugin::Config::Simple; . . . use CGI::FormBuilder; use CGI; . . . sub cgiapp_init { my $self = shift; $self->config_file('/var/lib/cf/tbd/regform/Registration.ini'); my $lib = $self->config_param('library'); push @INC, $lib; # use lib qw{/home/hesco/anmc/sb/Registration/Registration/lib}; require Registration::WWW::htmlgui; require Registration::DB; my $dbh = dbh(); # my $dbh = Registration::DB->connect($self->config_param('db_engine +'),$self->config_param('host_name'),$sel f->config_param('db_name'),$self->config_param('db_user'),$self->confi +g_param('db_pw')); my $result = auth_config($dbh); } sub dbh { my $self = shift; $self->config_file('/var/lib/cf/tbd/regform/Registration.ini'); my $dbh = Registration::DB->connect( $self->config_param('db_engine'), $self->config_param('host_name'), $self->config_param('db_name'), $self->config_param('db_user'), $self->config_param('db_pw') ); return $dbh; }

In reply to Need help untangling inheritance and scope in CGI::App module. by hesco

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (9)
    As of 2021-01-24 19:05 GMT
    Find Nodes?
      Voting Booth?