NMStreq idea: configuration defaults file

View: New views
1 Messages — Rating Filter:   Alert me  

NMStreq idea: configuration defaults file

by David Cohen-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I modified my copy of NMStreq.pm to optionally read a second configuration file of default values.  It makes maintaining many TFMail configuration files easier.

In each primary/_config configuration file that I want to use defaults for settings I didn't specify, I set "defaults" to a filename (without extension) of a configuration file containing default values.

I added the following 9 lines in sub new, after the primary configuration file is read, and before CGI parameters are loaded:

   my $cfg_name2 = $self->config('defaults');
   if ($cfg_name2)
    {
     my $config2 = $self->_read_config_file($cfg_name2);
     while ( my($key, $val) = each %$config2 )
      {
        $self->{r}{config}{$key} = $val unless exists $self->{r}{config}{$key};
      }
    }

I am not a Perl expert, so I assume there are better code and methods to fulfill my objective.  For example, loading defaults for keys already set could be avoided by modifying sub _read_config_file.  That would also remove a loop and reduce memory use and code needed.  But, I avoided modifying existing code.

I joined this email list yesterday.

David

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Nms-cgi-devel mailing list
Nms-cgi-devel@...
https://lists.sourceforge.net/lists/listinfo/nms-cgi-devel
LightInTheBox - Buy quality products at wholesale price!