On Mon, 10 Nov 2003 14:24:11 +0800
Byron Hammond <[EMAIL PROTECTED]> wrote:
Hi Byron,
>Hi Enrico,
>
>Thanks for the great work on Apache::SessionManager.
>I started using Apache::Session thinking I didn't need
>Apache::SessionManager. How wrong I was :)
>I am using mod_perl with Apache::DBI for persistent db
>connections and was wondering if I can use this with
>Apache::SessionManager?
Yes, you can. Transparently of course.
>Since I already have a database handle, I can use
>the following code to get Apache::Session to use it.
>
>my %session;
>tie %session, 'Apache::Session::Postgres', undef,
>{
> Handle => $dbh,
> Commit => 1,
>};
>
>
>I was hoping to make use of my persistent database
>connection with Apache::SessionManager but the following
>doesn't seem to work.
>
>PerlSetVar SessionManagerStore Postgres
>PerlSetVar SessionManagerStoreArgs "Handle => $dbh, Commit => 1"
Mmmh, this is the wrong way! :-)
>Basically, as long as Apache::SessionManager calls DBI->connect
>with the same parameters that I do when I setup my initial
>persistent connection, I'll be ok. I was hoping to not
>dive into code to enforce this though.
Apache::DBI overrides DBI 'connect' and 'disconnect' methods and it intercepts
all related calls (including Apache::SessionManager DBI calls) by returning
cached connections, if any.
Simply add a line like:
PerlModule Apache::DBI
in your httpd.conf, or:
use Apache::DBI;
in a startup.pl file.
However, remember that you _must_ load Apache::DBI module before DBI or any
module that uses it!
For testing purpose, you can enable perl-status console by putting (before
loading Apache::DBI) lines like:
<Location /perl-status>
SetHandler perl-script
PerlHandler Apache::Status
# or PerlResponseHandler Apache::Status in mod_perl 2
</Location>
You will see in the 'DBI connections' page, the cached datasource (in current
child) used by Apache::Session::* plugin datastore you've chosen. (I also
suggest to start httpd in single mode with -X option)
by
- Enrico
PS: I'm packaging Apache::SessionManager in order to support mod_perl 2 API (now
you can use A::SM under Apache::compat layer) and I'll add a section on cookpod
to explain how to use A::SM with A::DBI. Thanks for your observation! ;-)
--
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html