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

Re: [cgiapp] Calling CGI::Application::Plugin::ConfigAuto from cgiapp_init


On Sun, 12 Dec 2004 21:25:44 -0500, Sergej Zoubok <suppressed> wrote:
 Hi folks,

 In further generalizing the structure of a C::A app I thought to use
 CGI::Application::Plugin::ConfigAuto. Since I'm already using some
 other plugins (DBH and Session) I'd like to be able to use the
 configuration parameters from the parsed config file to initialize
 those plugins in cgiap_init; making it easier to reuse my app via
 multiple instance scripts.

 I realized too late that in:

 > # In my instance script
 my $app = WebApp->new();
 $app->cfg_file('config.pl');
 > $app->run();

 cgiapp_init is called before the config file is parsed; causing the
 plugin to die.

 C-A-P-ConfigAuto seems very convenient for accessing config
 parameters in run modes but not in cgiapp_init or setup. I could go
 back to passing a %config around but I'm wondering if I'm missing
 something about the use of the plugin.

It might be worthwhile for the CAP::AutoConfig module to look at the
PARAMS that are defined when you create the object:

my $app = WebApp->new( PARAMS => { cfg_file => 'config.pl' });
$app->run();

This would require an addition to CAP::AutoConfig, but it would be
minor.  All CAP::AutoConfig would need to do is if $self->cfg_file was
not called, then look in $self->param('cfg_file') for a potential
config file.

Cees,

Do you mean you would provide the name of the config file twice to provide a fall back for calls from cgi_init? As in:

# In my instance script
my $app = WebApp->new(PARAMS => { cfg_file => 'config.pl' });
$app->cfg_file('config.pl');
$app->run();

OR that the plugin would call cfg_file from within the application module's cgi_init using the parameter passed via new? Or something else entirely? :-)

Best,
Sergej






---------------------------------------------------------------------
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.