techcode has asked for the wisdom of the Perl Monks concerning the following question:
Problem is that to use the CGI::Session for CGI::Application I have to configure it during setup time. I need to either pass it DBH which means I already need to be connected to DB, or parameters that will be used to create DBH and connect by the CGI::Session itself.
In first case (giving it DBH):I'm not using DBI directly but from a module that I wrote which is sort of DB abstraction. I've implemented a Singleton pattern in it - so there is only one connection trougths application. And the way I send DBH to CGI::Session is by requesting it from my module.
Obviosly I already need to be connected at the time when I'm sending DBH to it. Maybe there is some way (TIE perhaps?) to catch all calls that CGI::Session would make on that DBH, and first connect and then execute them?### Set the configs for Sessions ### $self->session_config( CGI_SESSION_OPTIONS => ["driver:MySQL;serializer:Storab +le", $self->query, {Handle => $DB->dbh()}] );
Only solution that I know would work and how to do it (but not the nicest one) is to change CGI::Session just a bit ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using CGI:App and Session plugin - double DB connection fix.
by Tanktalus (Canon) on Sep 14, 2005 at 23:16 UTC | |
by techcode (Hermit) on Sep 15, 2005 at 07:41 UTC | |
|
Re: Using CGI:App and Session plugin - double DB connection fix.
by johnnywang (Priest) on Sep 14, 2005 at 17:22 UTC | |
by techcode (Hermit) on Sep 14, 2005 at 18:22 UTC | |
|
Re: Using CGI:App and Session plugin - double DB connection fix.
by cees (Curate) on Sep 14, 2005 at 23:52 UTC | |
by techcode (Hermit) on Sep 15, 2005 at 07:42 UTC | |
by cees (Curate) on Sep 15, 2005 at 12:54 UTC |