cvsuser 04/02/02 13:22:08
Modified: App-Context/lib App.pm
Log:
cleaned up some debug and option naming in code
Revision Changes Path
1.8 +27 -27 p5ee/App-Context/lib/App.pm
Index: App.pm
===================================================================
RCS file: /cvs/public/p5ee/App-Context/lib/App.pm,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -r1.7 -r1.8
--- App.pm 3 Dec 2003 16:14:46 -0000 1.7
+++ App.pm 2 Feb 2004 21:22:08 -0000 1.8
@@ -1,6 +1,6 @@
#############################################################################
-## $Id: App.pm,v 1.7 2003/12/03 16:14:46 spadkins Exp $
+## $Id: App.pm,v 1.8 2004/02/02 21:22:08 spadkins Exp $
#############################################################################
package App;
@@ -249,15 +249,15 @@
=head2 Global Variables
* Global Variable: $App::DEBUG integer
- * Global Variable: $App::DEBUGFILE file for debug output
- * Global Variable: %App::dbgscope scope for debug output
+ * Global Variable: $App::DEBUG_FILE file for debug output
+ * Global Variable: %App::debug_scope scope for debug output
=cut
if (!defined $App::DEBUG) {
$App::DEBUG = 0;
- $App::DEBUGFILE = "";
- %App::dbgscope = ();
+ $App::DEBUG_FILE = "";
+ %App::debug_scope = ();
}
#################################################################
@@ -278,17 +278,17 @@
}
if ($debug) {
foreach $pkg (split(/,/,$debug)) {
- $App::debugscope{$pkg} = 1;
+ $App::debug_scope{$pkg} = 1;
}
}
}
- my $debugfile = $App::options{debugfile};
- if ($debugfile) {
- if ($debugfile !~ /^[>|]/) {
- $debugfile = ">> $debugfile";
+ my $debug_file = $App::options{debug_file};
+ if ($debug_file) {
+ if ($debug_file !~ /^[>|]/) {
+ $debug_file = ">> $debug_file";
}
- open(App::DEBUGFILE, $debugfile);
+ open(App::DEBUG_FILE, $debug_file);
}
$App::trace_subs = 0;
@@ -550,53 +550,53 @@
&App::sub_entry if ($App::trace_subs);
my $self = shift;
- my ($name, $conf, $i);
- if ($#_ == -1) { # if no conf supplied (the normal case)
- $conf = (%App::options) ? \%App::options : {}; # refer to conf hash
+ my ($name, $options, $i);
+ if ($#_ == -1) { # if no options supplied (the normal case)
+ $options = (%App::options) ? \%App::options : {}; # options hash
$name = "default"; # name of the singleton is default
}
else { # named args were supplied ...
if (ref($_[0]) eq "HASH") { # ... as a hash reference
- $conf = shift; # note that a copy is *not* made
+ $options = shift; # note that a copy is *not* made
$name = shift if ($#_ % 2 == 0); # get name if it exists (odd#)
for ($i = 0; $i < $#_; $i++) { # copy other named args
- $conf->{$_[$i]} = $_[$i+1]; # into the conf hash
+ $options->{$_[$i]} = $_[$i+1]; # into the options hash
}
}
else { # ... as a list of var/values
$name = shift if ($#_ % 2 == 0); # if odd #, first is the name
- $conf = ($#_ > -1) ? { @_ } : {}; # the rest are named args
+ $options = ($#_ > -1) ? { @_ } : {}; # the rest are named args
}
- $name = $conf->{name} if (!$name); # if name not given, look in conf
+ $name = $options->{name} if (!$name); # if not given, look in options
$name = "default" if (!$name); # use "default" as name
}
return ($context{$name}) if (defined $context{$name}); # return context
- if (! $conf->{context_class}) {
+ if (! $options->{context_class}) {
if (defined $ENV{APP_CONTEXT_CLASS}) { # env variable set?
- $conf->{context_class} = $ENV{APP_CONTEXT_CLASS};
+ $options->{context_class} = $ENV{APP_CONTEXT_CLASS};
}
else { # try autodetection ...
my $gateway = $ENV{GATEWAY_INTERFACE};
if (defined $gateway && $gateway =~ /CGI-Perl/) { # mod_perl?
- $conf->{context_class} = "App::Context::ModPerl";
+ $options->{context_class} = "App::Context::ModPerl";
}
elsif ($ENV{HTTP_USER_AGENT}) { # running as CGI script?
- $conf->{context_class} = "App::Context::HTTP";
+ $options->{context_class} = "App::Context::HTTP";
}
else { # assume it is from the command line
- $conf->{context_class} = "App::Context::Cmd";
+ $options->{context_class} = "App::Context::Cmd";
}
}
}
- if (!$conf->{prefix}) { # if this isn't already set
+ if (!$options->{prefix}) { # if this isn't already set
if ($ENV{PREFIX}) { # but it's set in the environment
- $conf->{prefix} = $ENV{PREFIX}; # then set it
+ $options->{prefix} = $ENV{PREFIX}; # then set it
}
}
# instantiate Context and cache it (it's reference) for future use
- $context{$name} = $self->new($conf->{context_class}, "new", $conf);
+ $context{$name} = $self->new($options->{context_class}, "new", $options);
&App::sub_exit($context{$name}) if ($App::trace_subs);
return($context{$name});