cvsuser 02/01/16 10:32:47
Modified: P5EEx/Blue/P5EEx/Blue Context.pm Reference.pm Service.pm
P5EEx/Blue/P5EEx/Blue/Config File.pm
Log:
minor updates
Revision Changes Path
1.7 +9 -6 p5ee/P5EEx/Blue/P5EEx/Blue/Context.pm
Index: Context.pm
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Context.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -r1.6 -r1.7
--- Context.pm 11 Dec 2001 05:03:46 -0000 1.6
+++ Context.pm 16 Jan 2002 18:32:47 -0000 1.7
@@ -1,6 +1,6 @@
#############################################################################
-## $Id: Context.pm,v 1.6 2001/12/11 05:03:46 spadkins Exp $
+## $Id: Context.pm,v 1.7 2002/01/16 18:32:47 spadkins Exp $
#############################################################################
package P5EEx::Blue::Context;
@@ -362,10 +362,10 @@
$lcf_type = lcfirst($type);
$config = $self->config();
- $service_config = $config->{$lcf_type}{$name};
+ $service_config = $config->{$type}{$name};
- #$session = $self->session();
- #$service_session = $session->{$type}{$name};
+ $session = $self->session();
+ $service_session = $session->{$type}{$name};
if (defined $service_config) {
$new_config = 0;
@@ -474,7 +474,7 @@
# ?why was this code here? we don't put anything in the service_session in this
routine.
# (it is certainly benign, but I will probably remove it.)
- if (!defined $session->{$type}{$name} && !$lightweight && (%$service_session)) {
+ if (!defined $session->{$type}{$name} && !$lightweight && $service_session &&
(%$service_session)) {
$session->{$type}{$name} = $service_session;
}
@@ -811,11 +811,14 @@
=cut
+my %debugscope;
+
sub dbg {
my ($self, $class, $method, $level) = @_;
return 0 if (! $P5EEx::Blue::Context::DEBUG);
return 0 if (defined $level && $P5EEx::Blue::Context::DEBUG < $level);
- my $debugscope = $self->{debugscope};
+ my ($debugscope);
+ $debugscope = (ref($self) eq "") ? \%debugscope : $self->{debugscope};
return 1 if (! defined $debugscope);
return 1 if (! %$debugscope);
return 1 if (! defined $class);
1.2 +5 -4 p5ee/P5EEx/Blue/P5EEx/Blue/Reference.pm
Index: Reference.pm
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Reference.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -r1.1 -r1.2
--- Reference.pm 3 Jan 2002 18:19:15 -0000 1.1
+++ Reference.pm 16 Jan 2002 18:32:47 -0000 1.2
@@ -1,10 +1,10 @@
#############################################################################
-## $Id: Reference.pm,v 1.1 2002/01/03 18:19:15 spadkins Exp $
+## $Id: Reference.pm,v 1.2 2002/01/16 18:32:47 spadkins Exp $
#############################################################################
package P5EEx::Blue::Reference;
-$VERSION = do { my @r=(q$Revision: 1.1 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
+$VERSION = do { my @r=(q$Revision: 1.2 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
use strict;
@@ -416,11 +416,12 @@
return {} if ($#_ == -1);
if (ref($_[0]) ne "") {
return $_[0] if ($#_ == 0);
- P5EEx::Blue::Exception->throw(error => "create(): Args supplied with an
ARRAY ref\n")
+ P5EEx::Blue::Exception->throw(error => "Reference->create(): args supplied
with an ARRAY ref\n")
if (ref($_[0]) eq "ARRAY");
my ($ref, $i);
$ref = shift;
for ($i = 0; $i < $#_; $i += 2) {
+ print "arg: $_[$i] => $_[$i+1]\n";
$ref->{$_[$i]} = $_[$i+1];
}
return $ref;
@@ -430,7 +431,7 @@
return [ @_ ];
}
elsif ($#_ % 2 == 0) {
- P5EEx::Blue::Exception->throw(error => "create(): Odd number of named
parameters\n");
+ P5EEx::Blue::Exception->throw(error => "Reference->create(): Odd number of
named parameters\n");
}
return { @_ };
}
1.6 +8 -43 p5ee/P5EEx/Blue/P5EEx/Blue/Service.pm
Index: Service.pm
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Service.pm,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -w -r1.5 -r1.6
--- Service.pm 6 Jan 2002 20:57:07 -0000 1.5
+++ Service.pm 16 Jan 2002 18:32:47 -0000 1.6
@@ -1,6 +1,6 @@
#############################################################################
-## $Id: Service.pm,v 1.5 2002/01/06 20:57:07 spadkins Exp $
+## $Id: Service.pm,v 1.6 2002/01/16 18:32:47 spadkins Exp $
#############################################################################
package P5EEx::Blue::Service;
@@ -115,13 +115,14 @@
my ($config, $service_type);
$config = P5EEx::Blue::P5EE->config();
$service_type = $self->service_type();
+ $self->{global_config} = $config;
$self->{config} = $config->{$service_type}{$name};
}
else {
$self->{config} = $args; # this is all there is
}
- $self->init_service($args);
+ $self->init($args);
return $self;
}
@@ -181,53 +182,17 @@
=cut
#############################################################################
-# Method: init_service()
-#############################################################################
-
-=head2 init_service()
-
-The init_service() method is called from within the standard Service
-constructor.
-It allows subclasses of the Service to customize the behavior of the
-constructor by overriding the init_service() method.
-The init_service() method in this class simply calls the init()
-method to allow each service instance to initialize itself.
-
- * Signature: init_service($named)
- * Param: $named {} [in]
- * Return: void
- * Throws: P5EEx::Blue::Exception
- * Since: 0.01
-
- Sample Usage:
-
- $service->init_service($args);
-
-=cut
-
-sub init_service {
- my ($self, $args) = @_;
- $self->init($args);
-}
-
-#############################################################################
# Method: init()
#############################################################################
=head2 init()
-The init() method is called from within the standard Service constructor.
-The init() method in this class does nothing.
+The init() method is called from within the standard Service
+constructor.
It allows subclasses of the Service to customize the behavior of the
constructor by overriding the init() method.
-
-The difference between init_service() and init() is twofold.
-First, init_service() is called before init().
-Second, the init_service() method is expected to be overridden in the
-base class of the particular service, whereas init() is expected to
-be overridden in the specific class of the service.
-(i.e. init_service() is overridden in P5EEx::Blue::Repository,
-whereas init() is overridden in P5EEx::Blue::Repository::DBI.)
+The init() method in this class simply calls the init()
+method to allow each service instance to initialize itself.
* Signature: init($named)
* Param: $named {} [in]
@@ -237,7 +202,7 @@
Sample Usage:
- $service->init($args);
+ $service->init(\%args);
=cut
1.3 +24 -13 p5ee/P5EEx/Blue/P5EEx/Blue/Config/File.pm
Index: File.pm
===================================================================
RCS file: /cvs/public/p5ee/P5EEx/Blue/P5EEx/Blue/Config/File.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -r1.2 -r1.3
--- File.pm 11 Dec 2001 05:03:46 -0000 1.2
+++ File.pm 16 Jan 2002 18:32:47 -0000 1.3
@@ -1,10 +1,10 @@
#############################################################################
-## $Id: File.pm,v 1.2 2001/12/11 05:03:46 spadkins Exp $
+## $Id: File.pm,v 1.3 2002/01/16 18:32:47 spadkins Exp $
#############################################################################
package P5EEx::Blue::Config::File;
-$VERSION = do { my @r=(q$Revision: 1.2 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
+$VERSION = do { my @r=(q$Revision: 1.3 $=~/\d+/g); sprintf "%d."."%02d"x$#r,@r};
use P5EEx::Blue::P5EE;
use P5EEx::Blue::Config;
@@ -17,7 +17,9 @@
my $args = $self->SUPER::create(@_);
local(*FILE);
- my ($file, $testfile, $dir, @files, $filetype, $serializer_class, $open);
+ my ($file, $testfile, $dir, @files, $filebase, $filetype, $scriptbase);
+ my ($serializer_class, $open);
+
$file = $args->{configFile};
$file = $ENV{P5EE_CONFIG_FILE} if (!$file);
$serializer_class = $ENV{P5EE_CONFIG_FILE_SERIALIZER};
@@ -31,20 +33,29 @@
}
$dir = "." if (!$dir);
+ $scriptbase = $0;
+ $scriptbase =~ s!.*/!!; # remove leading path
+ $scriptbase =~ s!\.[^\.]+$!!; # remove trailing extension (i.e. ".cgi")
+
if (!$file) { # no file specified
- foreach $filetype qw(pl xml ini properties perl conf) {
- $testfile = ($dir eq ".") ? "config.$filetype" :
"$dir/config.$filetype";
+ CONFIGFILE: foreach $filetype qw(pl xml ini properties perl conf) {
+ foreach $filebase ($scriptbase, "config") {
+ $testfile = ($dir eq ".") ? "$filebase.$filetype" :
"$dir/$filebase.$filetype";
if (-r $testfile) {
$file = $testfile;
- last;
+ last CONFIGFILE;
}
}
}
-
+ }
+ else {
+ # the file name was specified and it doesn't exist in the current
+ # directory, so look in the script directory
if (! -r $file && $dir ne ".") {
$testfile = "$dir/$file";
$file = $testfile if (-r $testfile);
}
+ }
if (!$file) {
P5EEx::Blue::Exception::Config->throw(
@@ -92,7 +103,7 @@
$serializer_class = "P5EEx::Blue::Serializer::Properties";
}
elsif ($filetype) {
- my $serializer = uc(substr($filetype,0,1)) . substr($filetype,1);
+ my $serializer = ucfirst($filetype);
$serializer_class = "P5EEx::Blue::Serializer::$serializer";
}
else {