develooper Front page | perl.cvs.p5ee | Postings from January 2012

[svn:p5ee] r15067 - p5ee/trunk/App-Repository/lib/App/Repository

From:
spadkins
Date:
January 3, 2012 10:15
Subject:
[svn:p5ee] r15067 - p5ee/trunk/App-Repository/lib/App/Repository
Message ID:
20120103181457.07A31184B86@xx12.develooper.com
Author: spadkins
Date: Tue Jan  3 10:14:55 2012
New Revision: 15067

Modified:
   p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm

Log:
support arbitrary DBI connection attributes to be set. (Useful for Oracle DRCP, etc.) (e.g. {repname}.dbiattr = xyz,foo=5)

Modified: p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm
==============================================================================
--- p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm	(original)
+++ p5ee/trunk/App-Repository/lib/App/Repository/DBI.pm	Tue Jan  3 10:14:55 2012
@@ -177,10 +177,25 @@
 
     return 1 if (defined $self->{dbh});
 
+    my $name    = $self->{name};
+    my $context = $self->{context};
+    my $options = $context->{options};
+
     while ((!$self->{dbh} || !$self->{dbh}->ping())) {
         my $dsn  = $self->_dsn();
         my $attr = $self->_attr();
 
+        if (exists $options->{"$name.dbiattr"}) {
+            foreach my $var (split(/,/, $options->{"$name.dbiattr"})) {
+                if ($var =~ /^([^=]+)=(.*)$/) {
+                    $attr->{$1} = $2;
+                }
+                else {
+                    $attr->{$var} = 1;
+                }
+            }
+        }
+
         eval {
             my $dbh = DBI->connect($dsn, $self->{dbuser}, $self->{dbpass}, $attr);
             $self->{dbh} = $dbh;
@@ -194,6 +209,7 @@
                 }
             }
         };
+
         if (my $e = $@) {
             if ($self->is_retryable_connection_error($e)) {
                 $self->{context}->log({level=>1},"DBI Exception (retrying) in _connect(): $e");



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About