[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb:[5004] trunk/LedgerSMB/Scripts/setup.pm



Revision: 5004
          http://ledger-smb.svn.sourceforge.net/ledger-smb/?rev=5004&view=rev
Author:   einhverfr
Date:     2012-07-16 10:15:15 +0000 (Mon, 16 Jul 2012)
Log Message:
-----------
Addressing missing dbh issues with setup script

Modified Paths:
--------------
    trunk/LedgerSMB/Scripts/setup.pm

Modified: trunk/LedgerSMB/Scripts/setup.pm
===================================================================
--- trunk/LedgerSMB/Scripts/setup.pm	2012-07-16 10:02:52 UTC (rev 5003)
+++ trunk/LedgerSMB/Scripts/setup.pm	2012-07-16 10:15:15 UTC (rev 5004)
@@ -26,6 +26,11 @@
 
 my $logger = Log::Log4perl->get_logger('LedgerSMB::Scripts::setup');
 
+sub _set_dbh {
+    my ($dbh) = @_;
+    $LedgerSMB::App_State::DBH=$dbh;
+}
+
 sub __default {
 
     my ($request) = @_;
@@ -270,6 +275,7 @@
     # Credentials set above via environment variables --CT
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
     my $dbh = $request->{dbh};
+    _set_dbh($dbh);
     $dbh->do('ALTER SCHEMA public RENAME TO sl28');
     $dbh->do('CREATE SCHEMA PUBLIC');
     # Copying contrib script loading for now
@@ -301,6 +307,7 @@
     $rc ||= $rc2;
 
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    _set_dbh($request->{dbh});
 
    @{$request->{salutations}} 
     = $request->call_procedure(procname => 'person__list_salutations' ); 
@@ -345,6 +352,7 @@
 
     # Credentials set above via environment variables --CT
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    _set_dbh($request->{dbh});
     $request->{dbh}->{AutoCommit} = 0;
     my $locale = $request->{_locale};
 
@@ -483,6 +491,7 @@
 
     # Credentials set above via environment variables --CT
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    _set_dbh($request->{dbh});
     $request->{dbh}->{AutoCommit} = 0;
     my $locale = $request->{_locale};
 
@@ -644,6 +653,7 @@
 
 
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    _set_dbh($request->{dbh});
     $request->{dbh}->{AutoCommit} = 0;
 
     @{$request->{salutations}} 
@@ -689,6 +699,7 @@
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}",
                                    $creds->{login},
                                    $creds->{password});
+    _set_dbh($request->{dbh});
     $request->{dbh}->{AutoCommit} = 0;
     $LedgerSMB::App_State::DBH = $request->{dbh};
     $request->{control_code} = $request->{employeenumber};
@@ -777,6 +788,7 @@
 
     # Credentials set above via environment variables --CT
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    _set_dbh($request->{dbh});
     my $dbh = $request->{dbh};
     $dbh->do('ALTER SCHEMA public RENAME TO lsmb12');
     $dbh->do('CREATE SCHEMA PUBLIC');
@@ -796,6 +808,7 @@
     $rc ||= $rc2;
 
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}");
+    _set_dbh($request->{dbh});
 
    @{$request->{salutations}} 
     = $request->call_procedure(procname => 'person__list_salutations' ); 
@@ -853,6 +866,7 @@
     # Credentials set above via environment variables --CT
     #avoid msg commit ineffective with AutoCommit enabled
     $request->{dbh} = DBI->connect("dbi:Pg:dbname=$request->{database}",$creds->{login},$creds->{password},{AutoCommit=>0});
+    _set_dbh($request->{dbh});
     my $dbh = $request->{dbh};
     my $sth = $dbh->prepare(
           'UPDATE defaults SET value = ? WHERE setting_key = ?'

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.