/[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.17 by joko, Thu Jan 30 21:42:22 2003 UTC revision 1.19 by joko, Tue Feb 18 19:22:11 2003 UTC
# Line 9  Line 9 
9  ## ------------------------------------------------------------------------  ## ------------------------------------------------------------------------
10  ##  ##
11  ##  $Log$  ##  $Log$
12    ##  Revision 1.19  2003/02/18 19:22:11  joko
13    ##  + fixed logging
14    ##
15    ##  Revision 1.18  2003/01/30 22:12:17  joko
16    ##  - removed/refactored old code: ->Data::Storage::Handler::Tangram|DBI
17    ##
18  ##  Revision 1.17  2003/01/30 21:42:22  joko  ##  Revision 1.17  2003/01/30 21:42:22  joko
19  ##  + minor update: renamed method  ##  + minor update: renamed method
20  ##  ##
# Line 108  sub new { Line 114  sub new {
114    
115    my $arg_locator = shift;    my $arg_locator = shift;
116    my $arg_options = shift;    my $arg_options = shift;
117      #my @args = @_;
118      #@args ||= ();
119    
120    if (!$arg_locator) {    if (!$arg_locator) {
121      $logger->critical( __PACKAGE__ . "->new: No locator passed in!" );      $logger->critical( __PACKAGE__ . "->new: No locator passed in!" );
122      return;      return;
123    }    }
124      
125      #print Dumper($arg_locator);
126    
127    #my $self = { STORAGEHANDLE => undef, @_ };    #my $self = { STORAGEHANDLE => undef, @_ };
128    my $self = { STORAGEHANDLE => undef, locator => $arg_locator, options => $arg_options };    my $self = { STORAGEHANDLE => undef, locator => $arg_locator, options => $arg_options };
129    #$logger->debug( __PACKAGE__ . "[$self->{locator}->{type}]" . "->new(@_)" );    #$logger->debug( __PACKAGE__ . "[$self->{locator}->{type}]" . "->new(@_)" );
130    $logger->debug( __PACKAGE__ . "[$arg_locator->{type}]" . "->new(@_)" );    $logger->debug( __PACKAGE__ . "[$arg_locator->{type}]" . "->new()" );
131    return bless $self, $class;    return bless $self, $class;
132  }  }
133    
# Line 181  sub _filter_AUTOLOAD { Line 191  sub _filter_AUTOLOAD {
191  }  }
192    
193    
 sub normalizeArgs {  
   my %args = @_;  
   if (!$args{dsn} && $args{meta}{dsn}) {  
     $args{dsn} = $args{meta}{dsn};  
   }  
   my @result = %args;  
   return @result;  
 }  
   
194  sub _accessStorageHandle {  sub _accessStorageHandle {
195    my $self = shift;    my $self = shift;
196    # TODO: to some tracelevel!    # TODO: to some tracelevel!
# Line 297  sub removeLogDispatchHandler { Line 298  sub removeLogDispatchHandler {
298    $logger->remove($name);    $logger->remove($name);
299  }  }
300    
 =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  
301    
302  1;  1;
303  __END__  __END__

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.19

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