On Sat, 2004-02-14 at 00:46, Morbus Iff wrote:
> >> (my MaxRequestsPerChild is set to 30)
>
> The webhost uses iHTML for ecommerce thingies, and our experience
> with various boxes and server versions is that weird shit happens
> if iHTML isn't cleaned out regularly. This may not be the case (the
> last time we experienced a specific problem with hanging MySQL
> processes associated with iHTML was about a year ago) recently,
> we've yet to find time to adequately run more tests.
>
> >Using a global for that is not such a good idea. Any value you put in
> >there will persist between requests. That is one common source of this
>
> Ignore this next question if too off-topic, then. How are other people
> handling user settings? For instance, LibDB::Settings determines a bunch
> of stuff for each and every request, depending on the user environment
> (script being run, the browser's AcceptLanguage, the user's chosen
> template, etc.). Since I want those values to be the same through
> all objects ($s1, $s2, $s3 should return the same setting value
> regardless whether it was changed by $s4), they're all stored in
> a global (to LibDB::Settings) %SETTINGS. How should I handle this
> from mod_perl's standpoint?
I'm always using a Singleton-Pattern like this:
Config.pm
--------------------8<--------------------
package Config;
our $INSTANCE;
sub new {
my $class = shift;
bless {
val1 => 100,
val2 => "tom",
val3 => 0
}, $class;
}
sub getInstance {
if( ! defined $INSTANCE ){
$INSTANCE = new Config();
}
}
sub getVal {
my $this = shift;
my $valname = shift;
return $this->{$valname};
}
sub setVal {
my $this = shift;
my $valname = shift;
$this->{$valname} = shift
}
sub cleanMeUp {
undef $INSTANCE;
}
--------------------8<--------------------
Handler.pm
--------------------8<--------------------
use Lib1;
use Lib2;
use Config;
sub handler {
## make sure we get a new object
## and not the cashed one
&Config::cleanMeUp()
my $config = &Config::getIntance();
&Lib1::foo();
&Lib2::foo();
print $config->getVal('val1') ## prints 100
print $config->getVal('val2') ## prints tim
print $config->getVal('val3') ## prints 5
}
--------------------8<--------------------
Lib1.pm
--------------------8<--------------------
sub foo {
my $config = &Config::getIntance();
$config->setVal( 'val2', 'tim' );
}
--------------------8<--------------------
Lib2.pm
--------------------8<--------------------
sub foo {
my $config = &Config::getIntance();
$config->setVal( 'val3', 5 );
}
--------------------8<--------------------
>
> >> What I'm seeing, with the same frequency as the above problem,
> >> is a warning that the object method ->connect can not be found.
> >> LibDB::DB->new returns a LibDB::DB::MySQL class (which itself
> >> uses DBI and DBD::mysql). LibDB::DB::MYSQL contains a ->connect
> >> function, which is a mere wrapper around DBI's. Why it can't be
> >> found perplexes me: enough reloads later, and database access
> >> is working just fine. This doesn't sound like caching whatsoever.
> >
> >Make sure you aren't opening a database connection during server
> >startup. Throw in a log statement where you connect to the database and
> >make sure it doesn't happen before you send in a request.
>
> I'm not, but realize that it's never getting to the actual database
> connection: instead, it's telling me that the ->connect routine
> doesn't even exist in the (correct) module.
>
> --
> Morbus Iff ( softcore vulcan pr0n rulezzzzz )
> Technical: http://www.oreillynet.com/pub/au/779
> Culture: http://www.disobey.com/ and http://www.gamegrene.com/
> icq: 2927491 / aim: akaMorbus / yahoo: morbus_iff / jabber.org: morbus
--
\\\||///
\\ - - //
( @ @ )
-oOo--( )--oOo----------------------------------------------------------
___ ___ tom schindl
o __ / / / innovative medientechnik planung AG
/ /\/\/ / / /__/ / __ mailto:[EMAIL PROTECTED]
/ / / / /_/ / / /___/ http://www.impire.de
/ voice:+43(512)34193431,fax:+43(512)34193420
Eduard-Bodem-Gasse 6, A-6020 Innsbruck, Austria, Software Engineering
------------------------------------------------------------------------
--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html