Runtime Database connections- one more time

[prev] [thread] [next] [Date index for 2005/01/23]

From: Daniel Collis Puro
Subject: Runtime Database connections- one more time
Date: 17:27 on 23 Jan 2005
Folks,

One more method I've tried out for putting in connection info at
run-time: manipulating the symbol table of my CDBI class (OOPC::DB) and
putting in the db_Main method directly.

###########################
package OOPC::Settings::Manage;
use strict;
use warnings;
use OOPC::DB;
use base 'OOPC::Web::Base';

sub setup{
    my $self=shift;

    #We set all the CDBI specific options in OOPC::Web::Base
    my $dbh=$self->param('dbh');

    #Install the db_Main subroutine into the OOPC::DB symbol table
    *OOPC::DB::db_Main=sub{return $dbh};

    $self->start_mode('list_namespaces');

$self->mode_param($self->param('settings')->{Global}->{run_mode_param});
    $self->run_modes(
		     list_namespaces=>'list_namespaces',
		     is_denied=>'is_denied',
		     AUTOLOAD=>'list_namespaces'
		    );
}
########################################

It works from the command line, and feels MUCH cleaner than using
"our()" . .  any mod_perl concerns?  I've manipulated the symbol table
before for some mod_perl apps (in AUTOLOAD to create and install methods
on the fly) and it worked fine.

Thoughts?

-DJCP

        -- 
        Dan Collis Puro
Chief Engineer
GeekUprising Internet Consultants
http://www.geekuprising.com
dan@xxxxxxxxxxxx.xxx
781-775-1338

Runtime Database connections- one more time
Daniel Collis Puro 17:27 on 23 Jan 2005

Re: Runtime Database connections- one more time
Perrin Harkins 18:48 on 23 Jan 2005

Re: Runtime Database connections- one more time
Bo Strinnholm 23:25 on 23 Jan 2005

Re: Runtime Database connections- one more time
Perrin Harkins 01:36 on 24 Jan 2005

Generated at 16:37 on 28 Jul 2005 by mariachi v0.52