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

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

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

revision 1.5 by joko, Sun Nov 17 06:35:18 2002 UTC revision 1.21 by jonen, Mon Dec 16 22:20:49 2002 UTC
# Line 1  Line 1 
1  #################################  ############################################
2  #  #
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.21  2002/12/16 22:20:49  jonen
7    #  + fixed bug at 'getObjectByGuid()'
8    #
9    #  Revision 1.20  2002/12/16 20:49:17  jonen
10    #  + added sub 'getObjectByGuid()'
11    #  + added functionality to use 'getObjectByGuid' at 'getObjectAsHash()'
12    #
13    #  Revision 1.19  2002/12/16 06:46:09  joko
14    #  + attempt to introduce a generic '_patchSchema' - cancelled!
15    #
16    #  Revision 1.18  2002/12/13 21:48:07  joko
17    #  + fix to 'sub sendQuery'
18    #
19    #  Revision 1.17  2002/12/12 02:51:09  joko
20    #  + cosmetics
21    #
22    #  Revision 1.16  2002/12/11 06:54:10  joko
23    #  + fix: encapsulated object-loading inside an 'eval'
24    #
25    #  Revision 1.15  2002/12/05 13:55:21  joko
26    #  + now utilizing 'object2hash' instead of 'var_deref'
27    #  + played around with having fresh-objects - no progress....
28    #
29    #  Revision 1.14  2002/12/05 09:40:30  jonen
30    #  + added option->{destroy} at getObject for unloading all instance
31    #
32    #  Revision 1.13  2002/12/05 07:59:04  joko
33    #  + now using Tie::SecureHash as a base for the COREHANDLE
34    #  + former public COREHANDLE becomes private _COREHANDLE now
35    #  + sub getCOREHANDLE
36    #
37    #  Revision 1.12  2002/12/04 11:34:49  joko
38    #  - $schema_tangram doesn't have to be in class?
39    #
40    #  Revision 1.11  2002/12/04 08:54:08  jonen
41    #  + untested bugfix: undef($object) after transform to hash at getObjectAsHash
42    #
43    #  Revision 1.10  2002/12/03 15:53:23  joko
44    #  + small bugfix regarding object hierarchy
45    #
46    #  Revision 1.9  2002/12/03 05:29:40  joko
47    #  + sub getObject
48    #  + sub getObjectAsHash
49    #
50    #  Revision 1.8  2002/12/01 22:25:51  joko
51    #  + now utilizing metadata from storage locator when connecting to DBI in "raw"-mode
52    #
53    #  Revision 1.7  2002/12/01 04:46:19  joko
54    #  + sub eraseAll
55    #
56    #  Revision 1.6  2002/11/29 05:02:30  joko
57    #  - sub getNewPerlObjectByPkgName (moved to libp.pm)
58    #  + sub getMetaInfo
59    #  - sub existsChildNode (moved to Abstract.pm)
60    #  + sub getListUnfiltered
61    #  + sub getListFiltered
62    #  + sub createCursor
63    #  + sub createSet
64    #  + sub sendQuery
65    #
66  #  Revision 1.5  2002/11/17 06:35:18  joko  #  Revision 1.5  2002/11/17 06:35:18  joko
67  #  + locator metadata can now be reached via ->{locator}  #  + locator metadata can now be reached via ->{locator}
68  #  - getChildNodes is now wrapped via COREHANDLE  #  - getChildNodes is now wrapped via COREHANDLE
# Line 25  Line 85 
85  #  Revision 1.1  2002/10/10 03:44:07  cvsjoko  #  Revision 1.1  2002/10/10 03:44:07  cvsjoko
86  #  + new  #  + new
87  #  #
88  #  ############################################
89  #################################  
90    
91  package Data::Storage::Handler::Tangram;  package Data::Storage::Handler::Tangram;
92    
93  use strict;  use strict;
94  use warnings;  use warnings;
95    
96    use base ("Data::Storage::Handler");
97  use base ("Data::Storage::Handler::Abstract");  use base ("Data::Storage::Handler::Abstract");
98    
99  use Tangram;  use Tangram;
100  use Data::Dumper;  use Data::Dumper;
101    use libp qw( getNewPerlObjectByPkgName );
102    use Data::Storage::Result::Tangram;
103    use Data::Compare::Struct qw( isEmpty );
104    use Data::Transform::Deep qw( object2hash );
105    use Data::Transform::Encode qw( var2utf8 );
106    
107    
108  # get logger instance  # get logger instance
109  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
110    
111    
112  our $metainfo = {  # this holds the complete instantiated schema from tangram
113    'disconnectMethod' => 'disconnect',  my $schema_tangram;
 };  
114    
115  sub getNewPerlObjectByPkgName {  sub getMetaInfo {
116    my $pkgname = shift;    my $self = shift;
117    my $args = shift;    $logger->debug( __PACKAGE__ . "->getMetaInfo()"  );
118    $logger->debug( __PACKAGE__ . "->getNewPerlObjectByPkgName( pkgname $pkgname args $args )" );    return {
119    my $evstring = "use $pkgname;";      'disconnectMethod' => 'disconnect',
120    eval($evstring);    };
   $@ && $logger->error( __PACKAGE__ . ':' . __LINE__ . " Error in eval $evstring: " .  $@ );  
   return $pkgname->new($args);  
121  }  }
122    
123  sub _initSchema {  sub _initSchema {
124    my $self = shift;    my $self = shift;
125    $logger->debug( __PACKAGE__ . "->_initSchema()" );    $logger->debug( __PACKAGE__ . "->_initSchema()" );
126    #if (!$self->{schema_tangram}) {    #if (!$schema_tangram) {
127      my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } );      my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } );
128      $self->{schema_tangram} = $obj->getSchema();      $schema_tangram = $obj->getSchema();
129    #}    #}
130    if (!$self->{schema_tangram}) {    if (!$schema_tangram) {
131      $logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" );      $logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" );
132      return 0;      return 0;
133    }    }
134      #$self->_patchSchema();
135    return 1;    return 1;
136  }  }
137    
138    sub _patchSchema {
139      my $self = shift;
140      foreach (keys %{$schema_tangram->{classes}}) {
141        next if $schema_tangram->{classes}->{$_}->{abstract};
142        #next if ($_ ne 'TsBankAccount');
143        #$_ ne 'AbstractAccount' &&
144        print "class: $_", "\n";
145    #print Dumper($schema_tangram->{classes}->{$_});
146        # create new string property named 'guid'
147        my $tstring = Tangram::String->new();
148        $tstring->{name} = $tstring->{col} = 'guid';
149        # inject property into schema
150        #$schema_tangram->{classes}->{$_}->{root}->{SPECS}->[0]->{fields}->{string}->{$tstring->{name}} = $tstring;
151        print Dumper($schema_tangram->{classes}->{$_}->{root}->{SPECS}->[0]->{fields});
152      }
153    }
154    
155  sub connect {  sub connect {
156    
157      my $self = shift;      my $self = shift;
# Line 90  sub connect { Line 172  sub connect {
172    
173      return unless $self->_initSchema();      return unless $self->_initSchema();
174    
175        # create the main tangram storage object
176      #$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn );      #$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn );
177      $self->{COREHANDLE} = Tangram::Relational->connect( $self->{schema_tangram}, $dsn );      $self->{_COREHANDLE} = Tangram::Relational->connect( $schema_tangram, $dsn );
178    
179    #print "connect", "\n";
180    #my $core = $self->{_COREHANDLE};
181    #print Dumper($core);
182        
183        # some attempts for configuring the wrapped underlying dbi.....
184      #$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage();      #$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage();
185      #$self->{STORAGEHANDLE_UNDERLYING}->_configureCOREHANDLE();      #$self->{STORAGEHANDLE_UNDERLYING}->_configureCOREHANDLE();
186      #$self->_configureUnderlyingStorage;      #$self->_configureUnderlyingStorage;
187        
188        # ..... encapsulation wins!
189      $self->configureCOREHANDLE();      $self->configureCOREHANDLE();
190    
191    $self->{locator}->{status}->{connected} = 1;    $self->{locator}->{status}->{connected} = 1;
# Line 114  sub getChildNodes { Line 204  sub getChildNodes {
204    # create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE    # create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE
205    #my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} });    #my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} });
206    #my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} );    #my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} );
207      
208      # todo: should we retrieve information from the schema here
209      # rather than poorly getting table names from underlying dbi?
210    my $storage = $self->_getSubLayerHandle();    my $storage = $self->_getSubLayerHandle();
211    @nodes = @{$storage->getChildNodes()};    @nodes = @{$storage->getChildNodes()};
212    #$storage->_configureCOREHANDLE();    #$storage->_configureCOREHANDLE();
# Line 121  sub getChildNodes { Line 214  sub getChildNodes {
214  #print Dumper($self);  #print Dumper($self);
215    #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) {    #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) {
216        
217    $storage->disconnect();    # TODO: REVIEW
218      #$storage->disconnect();
219        
220    $self->{meta}->{childnodes} = \@nodes;    $self->{meta}->{childnodes} = \@nodes;
221        
# Line 130  sub getChildNodes { Line 224  sub getChildNodes {
224  }  }
225    
226    
 sub existsChildNode {  
   my $self = shift;  
   my $nodename = shift;  
   $logger->debug( __PACKAGE__ . "->getChildNode( nodename $nodename )" );  
   $self->getChildNodes() unless $self->{meta}->{childnodes};  
   #print Dumper($self->{meta}->{childnodes});  
   return grep $nodename, @{$self->{meta}->{childnodes}};  
 }  
   
   
227  sub testIntegrity {  sub testIntegrity {
228    
229    my $self = shift;    my $self = shift;
# Line 200  sub _configureUnderlyingStorage { Line 284  sub _configureUnderlyingStorage {
284    foreach my $key (keys %{$self->{dbi}}) {    foreach my $key (keys %{$self->{dbi}}) {
285      my $val = $self->{dbi}->{$key};      my $val = $self->{dbi}->{$key};
286      print "entry: $key; $val", "\n";      print "entry: $key; $val", "\n";
287      $self->{COREHANDLE}->{db}->{$key} = $val;      $self->{_COREHANDLE}->{db}->{$key} = $val;
288    }    }
289    #print Dumper($self->{COREHANDLE}->{db});    #print Dumper($self->{COREHANDLE}->{db});
290  }  }
# Line 216  sub configureCOREHANDLE { Line 300  sub configureCOREHANDLE {
300    
301    # apply configured modifications    # apply configured modifications
302      if (exists $self->{dbi}->{trace_level} && exists $self->{dbi}->{trace_file}) {      if (exists $self->{dbi}->{trace_level} && exists $self->{dbi}->{trace_file}) {
303        $self->{COREHANDLE}->{db}->trace($self->{dbi}->{trace_level}, $self->{dbi}->{trace_file});        $self->{_COREHANDLE}->{db}->trace($self->{dbi}->{trace_level}, $self->{dbi}->{trace_file});
304      }      }
305      if (exists $self->{dbi}->{RaiseError}) {      if (exists $self->{dbi}->{RaiseError}) {
306        $self->{COREHANDLE}->{db}->{RaiseError} = $self->{dbi}->{RaiseError};        $self->{_COREHANDLE}->{db}->{RaiseError} = $self->{dbi}->{RaiseError};
307      }      }
308      if (exists $self->{dbi}->{PrintError}) {      if (exists $self->{dbi}->{PrintError}) {
309        $self->{COREHANDLE}->{db}->{PrintError} = $self->{dbi}->{PrintError};        $self->{_COREHANDLE}->{db}->{PrintError} = $self->{dbi}->{PrintError};
310      }      }
311      if (exists $self->{dbi}->{HandleError}) {      if (exists $self->{dbi}->{HandleError}) {
312        $self->{COREHANDLE}->{db}->{HandleError} = $self->{dbi}->{HandleError};        $self->{_COREHANDLE}->{db}->{HandleError} = $self->{dbi}->{HandleError};
313      }      }
314    
315  }  }
# Line 235  sub deploySchema { Line 319  sub deploySchema {
319    my $args = shift;    my $args = shift;
320        
321    my $dsn = $self->{locator}->{dbi}->{dsn};    my $dsn = $self->{locator}->{dbi}->{dsn};
   #my $dsn = $self->{dbi}->{dsn};  
322    
323    $logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" );    $logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" );
324    
325    my $ok;    my $ok;
326    # TODO: is this DBI->connect okay here like it is? regarding errors.....???    if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) {
   if ( my $dbh = DBI->connect($dsn, '', '', {  
                                                       PrintError => 0,  
                                                     } ) ) {  
   
327      return unless $self->_initSchema();      return unless $self->_initSchema();
328            $ok = Tangram::Relational->deploy($schema_tangram, $dbh );
     $ok = Tangram::Relational->deploy($self->{schema_tangram}, $dbh );  
329      $dbh->disconnect();      $dbh->disconnect();
330    }    }
331    return $ok;    return $ok;
# Line 257  sub retreatSchema { Line 335  sub retreatSchema {
335    
336    my $self = shift;    my $self = shift;
337    my $dsn = $self->{locator}->{dbi}->{dsn};    my $dsn = $self->{locator}->{dbi}->{dsn};
   #my $dsn = $self->{dbi}->{dsn};  
338    
339    $logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" );    $logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" );
340    
341    my $ok;    my $ok;
342    if ( my $dbh = DBI->connect($dsn, '', '', {    if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) {
                                                       #PrintError => 0,  
                                                       #RaiseError => 0,  
                                                     } ) ) {  
343    
344      return unless $self->_initSchema();      return unless $self->_initSchema();
345            
346      #use Data::Dumper; print Dumper($self);      #use Data::Dumper; print Dumper($self);
347      $self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11");      $self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11");
348            
349      $ok = Tangram::Relational->retreat($self->{schema_tangram}, $dbh );      $ok = Tangram::Relational->retreat($schema_tangram, $dbh );
350      $ok = 2;    # answer is "maybe" for now since Tangram::Relational->retreat doesn't seem to return a valid status  
351                      # idea: test this by checking for count of tables in database -      # answer "$ok=2" means "maybe" for now - we have to patch this to a constant here because...
352                      #          problem with this: there may be some left not having been included to the schema      # - ... Tangram::Relational->retreat doesn't seem to return a valid status
353        # - possible improvement:
354        #   - test this by checking for count of tables in database
355        #   - problem with this: there may be some left not having been included to the schema
356        #   - maybe better: use "->getChildNodes"?
357        $ok = 2;
358    
359      $dbh->disconnect();      $dbh->disconnect();
360    
361    }    }
362    return $ok;    return $ok;
363  }  }
# Line 301  sub rebuildDbAndSchema { Line 382  sub rebuildDbAndSchema {
382    return $res;    return $res;
383  }  }
384    
385    sub getListUnfiltered {
386      my $self = shift;
387      my $nodename = shift;
388      my @results;
389      $logger->debug( __PACKAGE__ . "->getListUnfiltered( nodename => '" . $nodename . "' )" );
390      # get set of objects from odbms by object name
391      my $object_set = $self->{_COREHANDLE}->remote($nodename);
392      @results = $self->{_COREHANDLE}->select($object_set);
393      return \@results;
394    }
395    
396    sub getListFiltered {
397      my $self = shift;
398    
399      # redirect to unfiltered mode
400      #return $self->getListUnfiltered(@_);
401    
402      my $nodename = shift;
403      my $filters = shift;
404      my @results;
405      $logger->debug( __PACKAGE__ . "->getListFiltered( nodename => '" . $nodename . "' )" );
406    
407      #print Dumper($filters);
408      
409      my @tfilters;
410      
411      foreach my $filter (@$filters) {
412      
413        # get filter - TODO: for each filter
414        #my $filter = $filters->[0];
415      
416        # build filter
417        my $lexpr = $filter->{key};
418        #my $op = $filter->{op};
419        my $op = '=';
420        my $rexpr = $filter->{val};
421        my $tight = 100;
422        
423      #  my $tfilter = Tangram::Filter->new(
424      #    expr => "t1.$lexpr $op '$rexpr'",
425      #    tight => $tight,
426      #    objects => $objects,
427      #  );
428      
429        # HACK: build eval-string (sorry) to get filtered list - please give advice here
430        push @tfilters, '$remote->{' . $filter->{key} . '}' . " $filter->{op} '$filter->{val}'";
431    
432      }
433    
434      my $tfilter = join(' & ', @tfilters);
435    
436      # get set of objects from odbms by object name
437      my $remote = $self->{_COREHANDLE}->remote($nodename);
438      
439      # was:
440      #@results = $self->{COREHANDLE}->select($object_set, $tfilter);
441    
442      # is:
443      # HACK: build eval-string (sorry) to get filtered list - please give advice here
444      my $evalstring = 'return $self->{_COREHANDLE}->select($remote, ' . $tfilter . ');';
445      
446      # get filtered list/set
447      @results = eval($evalstring);
448      die $@ if $@;
449      
450      return \@results;
451    }
452    
453    sub createCursor {
454      my $self = shift;
455      my $node = shift;
456      my $cmdHandle = $self->{_COREHANDLE}->cursor($node);
457      my $result = Data::Storage::Result::Tangram->new( RESULTHANDLE => $cmdHandle );
458      return $result;
459    }
460    
461    sub createSet {
462      my $self = shift;
463    #print "-" x 80, "\n";
464    #print Dumper(@_);
465      my @objects = @_;
466      my $rh = Set::Object->new();
467      foreach (@objects) {
468        if (!isEmpty($_)) {
469    #print Dumper($_);
470          $rh->insert($_);
471        }
472      }
473      #print Dumper($rh->members());
474      my $result = Data::Storage::Result::Tangram->new( RESULTHANDLE => $rh );
475      return $result;
476    }
477    
478    sub sendQuery {
479      my $self = shift;
480      my $query = shift;
481      #my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';";
482      #my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql);
483    
484      #print Dumper($query);
485    
486      # HACK: special case: querying by id does not translate into a common tangram query
487      # just load the object by given id(ent)
488      if ($query->{criterias}->[0]->{key} eq 'id' && $query->{criterias}->[0]->{op} eq 'eq') {
489        #print "LOAD!!!", "\n";
490        #exit;
491        #return Set::Object->new( $self->{COREHANDLE}->load($query->{criterias}->[0]->{val}) );
492        my $ident = $query->{criterias}->[0]->{val};
493    #print "load obj", "\n";
494        #return $self->createSet() if $ident == 5;
495        $self->{_COREHANDLE}->unload($ident);
496        my $object = $self->{_COREHANDLE}->load($ident);
497    #print "get id", "\n";
498        my $oid = $self->{_COREHANDLE}->id($object);
499    #print Dumper($object);
500    #print "oid: $oid", "\n";
501        return $self->createSet($object);
502        #return $self->createSet( $self->{COREHANDLE}->load('300090018') );
503      }
504    
505      die("This should not be reached for now - redirect to \$self->getListFiltered() here!");
506    
507      # TODO: do a common tangram query here
508    
509      my @crits;
510      foreach (@{$query->{criterias}}) {
511        my $op = '';
512        $op = '=' if lc $_->{op} eq 'eq';
513        push @crits, "$_->{key}$op'$_->{val}'";
514      }
515      my $subnodes = {};
516      map { $subnodes->{$_}++ } @{$query->{subnodes}};
517      # HACK: this is hardcoded ;(    expand possibilities!
518      #my $crit = join(' AND ', @crits);
519      #my $sql = hash2Sql($query->{node}, $subnodes, 'SELECT', $crit);
520      #return $self->sendCommand($sql);
521      #my $h = $self->{COREHANDLE}->remote($query->{node});
522      #my $res = $self->{COREHANDLE}->select($h, $h->{);
523      return $self->createCursor($query->{node});
524    }
525    
526    sub eraseAll {
527      my $self = shift;
528      my $classname = shift;
529      my $remote = $self->{_COREHANDLE}->remote($classname);
530      my @objs = $self->{_COREHANDLE}->select($remote);
531      $self->{_COREHANDLE}->erase(@objs);
532    }
533    
534    sub createDb {
535      my $self = shift;
536      my $storage = $self->_getSubLayerHandle();
537      return $storage->createDb();
538    }
539    
540    sub getObject {
541      my $self = shift;
542      my $oid = shift;
543      my $options = shift;
544    
545      # TODO: create a deep_unload method (currently _all_ objects are unloaded)
546      # unload($oid) will only unload object, not deep object hashes
547      $self->{_COREHANDLE}->unload() if ($options->{destroy});
548    
549      # TODO: review this
550      #if (!$self->{COREHANDLE}) { return; }
551    
552      # TODO: review this
553      my $object = eval('$self->{_COREHANDLE}->load($oid);');
554      print $@, "\n" if $@;
555    
556      return $object if $object;
557    }
558    
559    sub getObjectByGuid {
560      my $self = shift;
561      my $guid = shift;
562      my $options = shift;
563      
564      # Guid and Classname is needed
565      if(!$guid || !$options->{classname}) {
566        return;
567      }
568      
569      # TODO: create a deep_unload method (currently _all_ objects are unloaded)
570      # unload($oid) will only unload object, not deep object hashes
571      $self->{_COREHANDLE}->unload() if ($options->{destroy});
572    
573      # search for object with given Classname and Guid
574      my $obj_tmp = $self->{_COREHANDLE}->remote($options->{classname});
575      my @result = $self->{_COREHANDLE}->select($obj_tmp, $obj_tmp->{guid} eq $guid);
576      
577      # we searched for global unique identifer of some object,
578      # so it think we can trust there would be only one result
579      if($result[0]) {
580        return $result[0];
581      } else {
582        return "No Object with Classname $options->{classname} and GUID $options->{guid} found!";
583      }
584      
585    }
586    
587    sub getObjectAsHash {
588      my $self = shift;
589      my $oid = shift;
590      my $options = shift;  
591      my $obj;
592      
593      if($options->{guid}) {
594        $obj = $self->getObjectByGuid($oid, $options);
595      } else {
596        $obj = $self->getObject($oid, $options);
597      }
598      
599      # build options (a callback to unload autovivified objects) for 'expand'
600      # TODO: use $logger to write to debug here!
601      my $cb; # = sub {};
602    =pod
603      if ($options->{destroy}) {
604        $options->{cb}->{destroy} = sub {
605          print "================ DESTROY", "\n";
606          my $object = shift;
607          #print Dumper($object);
608          $self->{_COREHANDLE}->unload($object);
609          #undef($object);
610        };
611      }
612    =cut
613    
614      my $hash = object2hash($obj, $options);
615      #$options->{cb}->{destroy}->($obj);
616      #$self->{_COREHANDLE}->unload($obj);
617      
618      # convert values in hash to utf8 to be ready for (e.g.) encapsulation in XML
619      # now done in object2hash
620      #var2utf8($hash) if ($options->{utf8});
621      
622      # old (wrong) attempts to get rid of used instances, if requested
623        #$obj->clear_refs;
624        #$self->{COREHANDLE}->unload($obj) if($options->{destroy});
625        #$obj->DESTROY;
626        #undef($obj) if($options->{destroy});
627      
628      return $hash;
629    }
630    
631    sub getSchema {
632      return $schema_tangram;
633    }
634    
635    sub getCOREHANDLE {
636      my $self = shift;
637      return $self->{_COREHANDLE};
638    }
639    
640  1;  1;

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.21

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