This message is more about loading configs via the 'instance' script than
about OOP or smashing hashes together.  I describe only what works for me
here ... ymmv.

> -----Original Message-----
> From: Mark Stosberg [mailto:[EMAIL PROTECTED]]
> To: Eric Moore
> Subject: Re: [cgiapp] Config::Simple
>
>
> Eric Moore wrote:
> >
> > Am I correct that now I would load this set of parameters through the
> > instance script?

I am doing just that, using XML::Config (same difference really.)  In my CGI
script (instance) I set a value
that lets my setup() find the file ...

>> SNIP >>

my $AuthApp = AuthApp->new(PARAMS => { 'config_file' =>
'C:\\Apache\\cfgs\\auth-demo.xml'} );

<< SNIP <<

Then, in my 'setup()' function I do this ...

>> SNIP >>

    # configure application
    my $cfg_file = $self->param('config_file');
    my $cfg = new XML::Config;
    my %conf = $cfg->load_conf($cfg_file);

    # install template path from the config file
    $self->tmpl_path(%conf->{'template_path'});

    # install global variable values from config file
    $service_name = %conf->{'service_name'};
    $service_url = %conf->{'service_url'};
    $session_life = %conf->{'session_life'};
    $session_context = %conf->{'service_id'};

<< SNIP <<


 [I do something like that and it works well for me. ]

Ditto.  At least it works for me right now ... but my app is currently still
simple, I've only implemented 15/30 run modes and am storing only 4 things
in my config, in the end I'll probably have like 30 or so.

Thoughts?  Flames?

-- Cory



> > and then in a subsequent instance script, if I wanted to
> overload one of the
> > previous parameters:
>
> I believe unless you are using something like mod_perl instance scripts
> don't see previous instance scripts. However, if want you mean to do is
> override a project wide default with something specific to your instance
> script, then you are close.
>
> This is a classic case of adding two hashes, with the second hash
> overriding the first where they collide. An idiomatic way to do this is:
>
> %combined_params = (%global_params, %instance_params);
>
> Then you could call:
>
> my $myapp = RegPack->new(
>       PARAMS = \%combined_params,
>  );
>
> and get what you want, I believe.
>
> Hope that helps,
>


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/cgiapp@lists.vm.com/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to