[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cgiapp] CAP::Plugin::ConfigAuto-Problem


Hello!

If I want to call $self->cfg() at the cgiapp_init-stage, I recieve the following error:

Error executing class callback in init stage: must call cfg_files() before calling cfg(). at [...]/AP_tiny_admin.pm line 98

How do I have to use the Plugin that I may use it at the init-stage?

Here are my codes:

# cgiapp.cgi

#!/Perl/bin/perl
use strict;
use warnings;

$ENV{'CGI_APP_DEBUG'} = 1;
$CGI::POST_MAX = 1024 * 100;

use FindBin qw($Bin);
use lib ($Bin, "$Bin/AP_tiny_admin");
use AP_tiny_admin;

my $webapp = AP_tiny_admin->new(
    TMPL_PATH => "$Bin/AP_tiny_admin/Template",
    PARAMS => {cfg_file => "$Bin/AP_tiny_admin/config/config.pl",},
);
$webapp->run();


# CAP.pm:

package AP_tiny_admin;

use strict;
use warnings;
use FindBin qw($Bin);
use Data::Dumper qw/Dumper/;
use CGI::Carp qw/ fatalsToBrowser /;
use Mime::Types;
use File::Find::Rule;
use Image::Magick;

use base qw(CGI::Application);
use CGI::Application::Plugin::ConfigAuto (qw/cfg cfg_file/);
use CGI::Application::Plugin::DBH (qw/dbh_config dbh/);
use CGI::Application::Plugin::DebugScreen;
use CGI::Application::Plugin::Session;
use CGI::Application::Plugin::MessageStack;
use CGI::Application::Plugin::Forward;
use CGI::Application::Plugin::Redirect;
use CGI::Application::Plugin::ValidateRM;

[... some setup & docs here ...]

sub cgiapp_init  {
    my $self    = shift;
    my %db_hash = %{$self->cfg('db')}; # line 98 here

    # use the same args as DBI->connect();
    $self->dbh_config(
                      $db_hash{'dsn'},
                      $db_hash{'db_user'},
                      $db_hash{'db_password'},
                      $db_hash{'db_attributes'},
                      );
} # /cgiapp_init

Is it possible to access the config-data during the setup()-method?

Greets, A. Becker

--
Erstellt mit Operas revolutionärem E-Mail-Modul: http://www.opera.com/mail/

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.