At 05:28 PM 5/15/00 -0400, you wrote:
>I use Class::Singleton in mod_perl apps with *no* problem
>whatsoever. In fact, it's pretty nifty to simply say:
>
> my $obj = $class->instance;
>
>anywhere in my application and have the object (whatever it is) simply
>pop up.
Well, after looking at the Class::Singleton class, I gave it a shot. After
hacking away at a ChildInitHandler, this is what I ended up with:
package X::Y::Apache::ChildInit;
use strict;
use X::Y::DB::SingletonServices;
use Apache;
##--------------------------------------------------------------------------
---------
sub handler
{
my $s = Apache->server;
my $dbs = X::Y::DB::SingletonServices->instance(
{ uri => $s->dir_config( 'DATABASE_URI' ),
userid => $s->dir_config( 'DATABASE_USERID' ),
password => $s->dir_config( 'DATABASE_PASSWORD' ),
options => { AutoCommit => 0,
RaiseError => 1,
PrintError => 0,
ChopBlanks => 1 } } );
$s->log_error( "$$: Services object allocated, handle=$dbs" );
}
1;
Perfect! I now have access to my services object everywhere!
Thanks for the point at Class::Singleton. I would have eventually written
my own, but with CPAN, what's the point?
Cheers!
-klm.
-------------------------------------------
Ken Miller, Consultant
Shetland Software Services Inc.