/[cvs]/nfo/perl/libs/Data/Storage.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.16 by joko, Mon Jan 20 16:52:13 2003 UTC revision 1.18 by joko, Thu Jan 30 22:12:17 2003 UTC
# Line 9  Line 9 
9  ## ------------------------------------------------------------------------  ## ------------------------------------------------------------------------
10  ##  ##
11  ##  $Log$  ##  $Log$
12    ##  Revision 1.18  2003/01/30 22:12:17  joko
13    ##  - removed/refactored old code: ->Data::Storage::Handler::Tangram|DBI
14    ##
15    ##  Revision 1.17  2003/01/30 21:42:22  joko
16    ##  + minor update: renamed method
17    ##
18  ##  Revision 1.16  2003/01/20 16:52:13  joko  ##  Revision 1.16  2003/01/20 16:52:13  joko
19  ##  + now using 'DesignPattern::Object' to create a new 'Data::Storage::Handler::Xyz' on demand - before we did this in a hand-rolled fashion  ##  + now using 'DesignPattern::Object' to create a new 'Data::Storage::Handler::Xyz' on demand - before we did this in a hand-rolled fashion
20  ##  ##
# Line 154  sub AUTOLOAD { Line 160  sub AUTOLOAD {
160            
161    # filtering AUTOLOAD calls and first-time-touch of the actual storage impl    # filtering AUTOLOAD calls and first-time-touch of the actual storage impl
162    if ($self->_filter_AUTOLOAD($method)) {    if ($self->_filter_AUTOLOAD($method)) {
163      $self->_accessStorage();      #print "=== FILTER!", "\n";
164        $self->_accessStorageHandle();
165      if ($self->{STORAGEHANDLE}) {      if ($self->{STORAGEHANDLE}) {
166        return $self->{STORAGEHANDLE}->$method(@_);        return $self->{STORAGEHANDLE}->$method(@_);
167      } else {      } else {
# Line 177  sub _filter_AUTOLOAD { Line 184  sub _filter_AUTOLOAD {
184  }  }
185    
186    
187  sub normalizeArgs {  sub _accessStorageHandle {
   my %args = @_;  
   if (!$args{dsn} && $args{meta}{dsn}) {  
     $args{dsn} = $args{meta}{dsn};  
   }  
   my @result = %args;  
   return @result;  
 }  
   
 sub _accessStorage {  
188    my $self = shift;    my $self = shift;
189    # TODO: to some tracelevel!    # TODO: to some tracelevel!
190      #print "=========== _accessStorage", "\n";
191    if ($TRACELEVEL) {    if ($TRACELEVEL) {
192      $logger->debug( __PACKAGE__ .  "[$self->{locator}->{type}]" . "->_accessStorage()" );      $logger->debug( __PACKAGE__ .  "[$self->{locator}->{type}]" . "->_accessStorageHandle()" );
193    }    }
194    if (!$self->{STORAGEHANDLE}) {    if (!$self->{STORAGEHANDLE}) {
195      return $self->_createStorageHandle();      return $self->_createStorageHandle();
# Line 292  sub removeLogDispatchHandler { Line 291  sub removeLogDispatchHandler {
291    $logger->remove($name);    $logger->remove($name);
292  }  }
293    
 =pod  
 sub getDbName {  
   my $self = shift;  
   my $dsn = $self->{locator}->{dbi}->{dsn};  
   $dsn =~ m/database=(.+?);/;  
   my $database_name = $1;  
   return $database_name;  
 }  
   
 sub testAvailability {  
   my $self = shift;  
   my $status = $self->testDsn();  
   $self->{locator}->{status}->{available} = $status;  
   return $status;  
 }  
   
 sub isConnected {  
   my $self = shift;  
   # TODO: REVIEW!  
   return 1 if $self->{STORAGEHANDLE};  
 }  
   
 sub testDsn {  
   my $self = shift;  
   my $dsn = $self->{locator}->{dbi}->{dsn};  
   my $result;  
   if ( my $dbh = DBI->connect($dsn, '', '', {  
                                                       PrintError => 0,  
                                                       } ) ) {  
       
     # TODO: REVIEW  
     $dbh->disconnect();  
       
     return 1;  
   } else {  
     $logger->warning( __PACKAGE__ .  "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr );  
   }  
 }  
 =cut  
294    
295  1;  1;
296  __END__  __END__

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.18

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed