[LON-CAPA-cvs] cvs: loncom /configuration Configuration.pm
albertel
lon-capa-cvs-allow@mail.lon-capa.org
Thu, 30 Aug 2007 20:19:35 -0000
albertel Thu Aug 30 16:19:35 2007 EDT
Modified files:
/loncom/configuration Configuration.pm
Log:
- support having override PerlSetVar set in loncapa_apache_local*.conf
Index: loncom/configuration/Configuration.pm
diff -u loncom/configuration/Configuration.pm:1.13 loncom/configuration/Configuration.pm:1.14
--- loncom/configuration/Configuration.pm:1.13 Fri Sep 15 16:49:27 2006
+++ loncom/configuration/Configuration.pm Thu Aug 30 16:19:35 2007
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Configuration file reader
#
-# $Id: Configuration.pm,v 1.13 2006/09/15 20:49:27 raeburn Exp $
+# $Id: Configuration.pm,v 1.14 2007/08/30 20:19:35 albertel Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -34,7 +34,7 @@
package LONCAPA::Configuration;
-$VERSION = sprintf("%d.%02d", q$Revision: 1.13 $ =~ /(\d+)\.(\d+)/);
+$VERSION = sprintf("%d.%02d", q$Revision: 1.14 $ =~ /(\d+)\.(\d+)/);
use strict;
@@ -58,19 +58,33 @@
if ($configdir eq '') {
die("Couldn't find a directory containing $filename");
}
- open(CONFIG,'<'.$configdir.$filename) or
- die("Can't read $configdir$filename");
- while (my $configline=<CONFIG>) {
- if ($configline =~ /^[^\#]*PerlSetVar/) {
- my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
- chomp($varvalue);
- $perlvar{$varname}=$varvalue;
+ &process_file($configdir.$filename,\%perlvar);
+ if ($filename eq 'loncapa_apache.conf') {
+ my @files = glob($configdir.'loncapa_apache_local*.conf');
+ foreach my $file (@files) {
+ &process_file($file,\%perlvar);
}
}
- close(CONFIG);
}
- my $perlvarref=\%perlvar;
- return ($perlvarref);
+ return (\%perlvar);
+}
+
+# --------------- Subroutine process_file: helper routine
+# This subroutine does the actual file reading and reads PerlSetVar discovery
+# specified file, arguments are the filename and a ref to a hash to
+# place the values in
+sub process_file {
+ my ($file,$perlvar) = @_;
+ open(my $config,'<',$file) or
+ die("Can't read $file");
+ while (my $configline=<$config>) {
+ if ($configline =~ /^[^\#]*PerlSetVar/) {
+ my ($unused,$varname,$varvalue)=split(/\s+/,$configline);
+ chomp($varvalue);
+ $perlvar->{$varname}=$varvalue;
+ }
+ }
+ close($config);
}
#---------------------- Subroutine read_hosts: Read a LON-CAPA hosts.tab