--- nfo/perl/libs/Data/Storage.pm 2002/12/11 06:53:19 1.11 +++ nfo/perl/libs/Data/Storage.pm 2002/12/19 16:27:59 1.14 @@ -1,4 +1,4 @@ -# $Id: Storage.pm,v 1.11 2002/12/11 06:53:19 joko Exp $ +# $Id: Storage.pm,v 1.14 2002/12/19 16:27:59 joko Exp $ # # Copyright (c) 2002 Andreas Motl # @@ -7,6 +7,24 @@ ############################################ # # $Log: Storage.pm,v $ +# Revision 1.14 2002/12/19 16:27:59 joko +# - moved 'sub dropDb' to Data::Storage::Handler::DBI +# +# Revision 1.13 2002/12/17 21:54:12 joko +# + feature when using Tangram: +# + what? each object created should delivered with a globally(!?) unique identifier (GUID) besides the native tangram object id (OID) +# + patched Tangram::Storage (jonen) +# + enhanced Data::Storage::Schema::Tangram (joko) +# + enhanced Data::Storage::Handler::Tangram 'sub getObjectByGuid' (jonen) +# + how? +# + each concrete (non-abstract) class gets injected with an additional field/property called 'guid' - this is done (dynamically) on schema level +# + this property ('guid') gets filled on object creation/insertion from 'sub Tangram::Storage::_insert' using Data::UUID from CPAN +# + (as for now) this property can get accessed by calling 'getObjectByGuid' on the already known storage-handle used throughout the application +# +# Revision 1.12 2002/12/12 02:50:15 joko +# + this now (unfortunately) needs DBI for some helper functions +# + TODO: these have to be refactored to another scope! (soon!) +# # Revision 1.11 2002/12/11 06:53:19 joko # + updated pod # @@ -199,6 +217,9 @@ use Data::Storage::Locator; use Data::Dumper; +# TODO: wipe out! +use DBI; + # TODO: actually implement level (integrate with Log::Dispatch) my $TRACELEVEL = 0; @@ -364,23 +385,6 @@ return $database_name; } -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 ); - } -} - sub testAvailability { my $self = shift; my $status = $self->testDsn(); @@ -388,37 +392,27 @@ return $status; } +sub isConnected { + my $self = shift; + # TODO: REVIEW! + return 1 if $self->{STORAGEHANDLE}; +} -sub dropDb { +sub testDsn { my $self = shift; my $dsn = $self->{locator}->{dbi}->{dsn}; - - $logger->debug( __PACKAGE__ . "->dropDb( dsn $dsn )" ); - - $dsn =~ s/database=(.+?);//; - my $database_name = $1; - - my $ok; - + my $result; if ( my $dbh = DBI->connect($dsn, '', '', { PrintError => 0, } ) ) { - if ($database_name) { - if ($dbh->do("DROP DATABASE $database_name;")) { - $ok = 1; - } - } - + + # TODO: REVIEW $dbh->disconnect(); - + + return 1; + } else { + $logger->warning( __PACKAGE__ . "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr ); } - - return $ok; -} - -sub isConnected { - my $self = shift; - return 1 if $self->{STORAGEHANDLE}; } 1; @@ -547,7 +541,8 @@ - 'sub getACLByMethodname($id, $context)' - 'sub getACLByName($id, $context)' ( would require a kinda registry to look up these very names pointing to arbitrary locations (code, data, ...) ) - + - add more hooks and various levels + - better integrate introduced 'getObjectByGuid'-mechanism from Data::Storage::Handler::Tangram =head3 LINKS / REFERENCES