--- nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2002/12/05 09:40:30 1.14 +++ nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2002/12/05 13:55:21 1.15 @@ -1,8 +1,12 @@ ############################################ # -# $Id: Tangram.pm,v 1.14 2002/12/05 09:40:30 jonen Exp $ +# $Id: Tangram.pm,v 1.15 2002/12/05 13:55:21 joko Exp $ # # $Log: Tangram.pm,v $ +# Revision 1.15 2002/12/05 13:55:21 joko +# + now utilizing 'object2hash' instead of 'var_deref' +# + played around with having fresh-objects - no progress.... +# # Revision 1.14 2002/12/05 09:40:30 jonen # + added option->{destroy} at getObject for unloading all instance # @@ -78,7 +82,7 @@ use libp qw( getNewPerlObjectByPkgName ); use Data::Storage::Result::Tangram; use Data::Compare::Struct qw( isEmpty ); -use Data::Transform::Deep qw( var_deref ); +use Data::Transform::Deep qw( object2hash ); use Data::Transform::Encode qw( var2utf8 ); @@ -506,13 +510,37 @@ my $oid = shift; my $options = shift; my $obj = $self->getObject($oid, $options); - my $deref = var_deref($obj); - var2utf8($deref) if ($options->{utf8}); - #$obj->clear_refs; - #$self->{COREHANDLE}->unload($obj) if($options->{destroy}); - #$obj->DESTROY; - #undef($obj) if($options->{destroy}); - return $deref; + + # build options (a callback to unload autovivified objects) for 'expand' + # TODO: use $logger to write to debug here! + my $cb; # = sub {}; +=pod + if ($options->{destroy}) { + $options->{cb}->{destroy} = sub { + print "================ DESTROY", "\n"; + my $object = shift; + #print Dumper($object); + $self->{_COREHANDLE}->unload($object); + #undef($object); + }; + } +=cut + + my $hash = object2hash($obj, $options); + #$options->{cb}->{destroy}->($obj); + #$self->{_COREHANDLE}->unload($obj); + + # convert values in hash to utf8 to be ready for (e.g.) encapsulation in XML + # now done in object2hash + #var2utf8($hash) if ($options->{utf8}); + + # old (wrong) attempts to get rid of used instances, if requested + #$obj->clear_refs; + #$self->{COREHANDLE}->unload($obj) if($options->{destroy}); + #$obj->DESTROY; + #undef($obj) if($options->{destroy}); + + return $hash; } sub getSchema {