cvsuser 02/04/19 07:37:20
Modified: P5EEx/Blue/cgi-bin p5x.PL
Log:
PATH_INFO: 1st segment is .conf file, 2nd segment is default_wname; propagate
p5ee_path_info to support TemplateGroup
Revision Changes Path
1.3 +31 -27 p5ee/P5EEx/Blue/cgi-bin/p5x.PL
Index: p5x.PL
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/cgi-bin/p5x.PL,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- p5x.PL 14 Apr 2002 03:50:40 -0000 1.2
+++ p5x.PL 19 Apr 2002 14:37:20 -0000 1.3
@@ -16,37 +16,41 @@
print OUT <<'!NO!SUBSTITUTIONS!';
#############################################################################
-# $Id: p5x.PL,v 1.2 2002/04/14 03:50:40 spadkins Exp $
+# $Id: p5x.PL,v 1.3 2002/04/19 14:37:20 spadkins Exp $
#############################################################################
BEGIN {
- my ($var, $value, $open, $file, $tmp, $default_wname);
+ my ($var, $value, $open, $file, $path_part);
+ my ($p5ee_path_info, $default_wname);
local(*FILE);
- %main::conf = ();
+
+ $p5ee_path_info = "";
+ $p5ee_path_info = $ENV{PATH_INFO} if (defined $ENV{PATH_INFO});
+
+ $file = "";
+ $path_part = "";
+ if ($p5ee_path_info =~ s!^/([^/]+)!!) {
+ $path_part = $1;
+ $file = "$path_part.conf"; # initialization config file
+ }
+
$open = 0; # assume we cannot find an openable config file ...
+ $open = open(main::FILE, "< $file") if ($file && !$open);
+
+ if ($open) {
$default_wname = "";
- if (defined $ENV{PATH_INFO} && $ENV{PATH_INFO} ne "/") {
- $file = $ENV{PATH_INFO} . ".conf"; # default config file based on
PATH_INFO
- $file =~ s!^/!!; # with no leading "/"
- $file =~ s!/!_!g; # and internal "/"s changed to "_"s
- $open = open(main::FILE, "< $file") if (-r $file);
- while (!$open && $file =~ s/_([a-zA-Z0-9\.-]+)\.conf/.conf/) {
- if ($default_wname) {
- $default_wname = "$1_$default_wname";
- }
- else {
- $default_wname = $1;
- }
- $open = open(main::FILE, "< $file") if (-r $file);
+ if ($p5ee_path_info =~ s!^/([^/]+)!!) {
+ $default_wname = $1; # default widget name
}
- if (!$open) {
- $default_wname = $ENV{PATH_INFO}; # default config default_wname based
on PATH_INFO
- $default_wname =~ s!^/!!; # with no leading "/"
- $default_wname =~ s!/!_!g; # and internal "/"s changed to "_"s
}
+ else {
+ $default_wname = $path_part;
}
- $open = open(main::FILE, "< $0.conf") if (!$open && -r "$0.conf");
- $open = open(main::FILE, "< p5ee.conf") if (!$open && -r "p5ee.conf");
+
+ $open = open(main::FILE, "< $0.conf") if (!$open);
+ $open = open(main::FILE, "< p5ee.conf") if (!$open);
+
+ %main::conf = ();
if ($open) {
while (<main::FILE>) {
chomp;
@@ -67,9 +71,9 @@
unshift(@INC, split(/ *, */,$main::conf{perlinc}));
}
}
- if ($default_wname) {
- $main::conf{defaultWname} = $default_wname;
- }
+
+ $main::conf{defaultWname} = $default_wname if ($default_wname);
+ $main::conf{p5ee_path_info} = $p5ee_path_info if ($p5ee_path_info);
}
#################################################################