>>This begs a big question that was answered somewhat indirectly:
>>Where do you create the database connection?
> 
> 
> I just always do it in Script_OnStart. The site I used this with is fine like this 
>... although having said that it doesn't make huge demands on the DB.
> 

Yes, use Script_OnStart for best effect.  If you want to cache your database
connections from request to request, which you need to do for heavy
connections like to Oracle, make sure to just "use Apache::DBI" before
you ever "use DBI".  The best place for this is in a mod_perl style
startup.pl script that you PerlRequire early on.  What Apache::DBI does
is make it so that a normal DBI->connect just returns a cached connection
next time it is asked for, so the connection caching is done for you
transparently.

> 
> 
>>Due to the persistant nature of mod_perl (about which I am just learning),
>>It is important to get that right.  Is this every time the page hits, or that
>>the page is compiled, ie the first time this particular apache process runs
>>this script?
> 

Script_OnStart is run before each time a script is executed regardless of
page compilation.

> 
>>Another stle question:  I have an app that use a lot of variables like $bgcolor
>>and such so I can change just one spot, and it changes all over the
>>application.  $Application->{bgcolor} seems like a logical place to put it.
>>

I would recommend you stay away from using $Application for much at all,
and especially things like this.  The current definition of Application_OnStart
is such that it may only get run once during the lifetime of you application,
as long as your application is in continual use.

Much better to configure a global hash like this:

#global.asa

use vars qw(%Config);
%Config = (
        bgcolor => 'white',
        text => 'black',
        );

and then reference your $Config{bgcolor} in your scripts.
If you would prefer to hijack $Application for this, you could set

   PerlSetVar AllowApplicationState 0

so that $Application would not be defined, then set your own
$Application like above in global.asa:

$Application = {
        bgcolor => 'white',
        text => 'black',
        };

The default $Application is a file dbm based cache, and though
not too slow, could hurt performance.  The latter $Application
which you could set up yourself is a per process in memory object
that would be perfect for read-only access.

Regards,

Josh
________________________________________________________________
Josh Chamas, Founder                   phone:925-552-0128
Chamas Enterprises Inc.                http://www.chamas.com
NodeWorks Link Checking                http://www.nodeworks.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to