--- nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2002/12/03 05:29:40 1.9 +++ nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2002/12/04 11:34:49 1.12 @@ -1,8 +1,17 @@ ############################################ # -# $Id: Tangram.pm,v 1.9 2002/12/03 05:29:40 joko Exp $ +# $Id: Tangram.pm,v 1.12 2002/12/04 11:34:49 joko Exp $ # # $Log: Tangram.pm,v $ +# Revision 1.12 2002/12/04 11:34:49 joko +# - $schema_tangram doesn't have to be in class? +# +# Revision 1.11 2002/12/04 08:54:08 jonen +# + untested bugfix: undef($object) after transform to hash at getObjectAsHash +# +# Revision 1.10 2002/12/03 15:53:23 joko +# + small bugfix regarding object hierarchy +# # Revision 1.9 2002/12/03 05:29:40 joko # + sub getObject # + sub getObjectAsHash @@ -68,6 +77,9 @@ my $logger = Log::Dispatch::Config->instance; +# this holds the complete instantiated schema from tangram +my $schema_tangram; + sub getMetaInfo { my $self = shift; $logger->debug( __PACKAGE__ . "->getMetaInfo()" ); @@ -79,11 +91,11 @@ sub _initSchema { my $self = shift; $logger->debug( __PACKAGE__ . "->_initSchema()" ); - #if (!$self->{schema_tangram}) { + #if (!$schema_tangram) { my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } ); - $self->{schema_tangram} = $obj->getSchema(); + $schema_tangram = $obj->getSchema(); #} - if (!$self->{schema_tangram}) { + if (!$schema_tangram) { $logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" ); return 0; } @@ -112,7 +124,7 @@ # create the main tangram storage object #$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn ); - $self->{COREHANDLE} = Tangram::Relational->connect( $self->{schema_tangram}, $dsn ); + $self->{COREHANDLE} = Tangram::Relational->connect( $schema_tangram, $dsn ); # some attempts for configuring the wrapped underlying dbi..... #$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage(); @@ -259,7 +271,7 @@ my $ok; if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) { return unless $self->_initSchema(); - $ok = Tangram::Relational->deploy($self->{schema_tangram}, $dbh ); + $ok = Tangram::Relational->deploy($schema_tangram, $dbh ); $dbh->disconnect(); } return $ok; @@ -280,7 +292,7 @@ #use Data::Dumper; print Dumper($self); $self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11"); - $ok = Tangram::Relational->retreat($self->{schema_tangram}, $dbh ); + $ok = Tangram::Relational->retreat($schema_tangram, $dbh ); # answer "$ok=2" means "maybe" for now - we have to patch this to a constant here because... # - ... Tangram::Relational->retreat doesn't seem to return a valid status @@ -453,8 +465,8 @@ sub eraseAll { my $self = shift; my $classname = shift; - my $remote = $self->{storage}->remote($classname); - my @objs = $self->{storage}->select($remote); + my $remote = $self->{COREHANDLE}->remote($classname); + my @objs = $self->{COREHANDLE}->select($remote); $self->{COREHANDLE}->erase(@objs); } @@ -479,7 +491,12 @@ my $obj = $self->getObject($oid); my $deref = var_deref($obj); var2utf8($deref) if ($options->{utf8}); + undef($obj) if($options->{destroy}); return $deref; } +sub getSchema { + return $schema_tangram; +} + 1;