[CDBI] print Class::DBI object to Data::Dumper

[prev] [thread] [next] [Date index for 2006/01/18]

From: Birgit Kellner
Subject: [CDBI] print Class::DBI object to Data::Dumper
Date: 15:26 on 18 Jan 2006
Hello,

I'm trying to print a Class::DBI object to a file handle, using=20
Data::Dumper, with a little subroutine that I've written to dump my=20
variables for testing purposes. However, not all of the data gets=20
dumped, and I'd like to find out why.

This is the routine:

sub dump {
my $variable =3D shift;# can be scalar, array ref or hash ref
my @loop;
push (@loop, $variable);# clumsy, but doesn't seem to work without it
my $caller =3D (caller(1))[3];
my $call_file =3D (caller(1))[1];
my $call_line =3D (caller(1))[2];
my $d =3D Data::Dumper->new(\@loop);
print TEST "$caller, $call_file, $call_line\n";
print TEST $d->Dump;

}

The object is retrieved in this routine:

sub show_single_term {
my @term =3D ILKB::Term->search(t_id =3D> "$in->{t_id}");# t_id passed=20
through the form
$vars->{terms} =3D \@term;
&dump($vars->{terms});

}


And this is the output to the filehandle:

main::show_single_term, /srv/www/cgi-bin/ilkb_edit/ilkb.cgi, 168
$VAR1 =3D [
bless( {
't_id' =3D> '75',
'lan_id' =3D> bless( {
'lan_id' =3D> '123'
}, 'ILKB::Language' ),
't_owner' =3D> 'Kellner',
'public' =3D> undef,
'c_id' =3D> bless( {
'c_id' =3D> '36'
}, 'ILKB::Concept' ),
'tgrp_id' =3D> '37',
'term' =3D> 'sv=C4=81rth=C4=81num=C4=81na'
}, 'ILKB::Term' )
];

My question is this: there is more data in the object than is actually=20
printed.
Here's the class definition:

package ILKB::Term;
use base 'ILKB::DBI';
my %columns =3D &main::get_class_columns("term");
ILKB::Term->table('term');
ILKB::Term->columns(Primary =3D> "$columns{Primary}" );
ILKB::Term->columns(Essential =3D> @{$columns{Essential}});
ILKB::Term->has_a('c_id' =3D> 'ILKB::Concept');
ILKB::Term->has_a('lan_id' =3D> 'ILKB::Language');
ILKB::Term->has_many('descriptive_item' =3D>'ILKB::DescriptiveItem');
ILKB::Term->has_many('term_translation' =3D>'ILKB::TermTranslation');

I know that the items related through ILKB::DescriptiveItem are=20
retrieved because they are printed to an HTML template that's called=20
later in the process. But for some reason they don't get dumped. Does=20
anyone know why? Or know of any alternative (and better) approaches to=20
dumping complete Class::DBI objects?

Thanks,

Birgit Kellner



_______________________________________________
ClassDBI mailing list
ClassDBI@xxxxx.xxxxxxxxxxxxxxxx.xxx
http://lists.digitalcraftsmen.net/mailman/listinfo/classdbi

[CDBI] print Class::DBI object to Data::Dumper
Birgit Kellner 15:26 on 18 Jan 2006

Generated at 09:31 on 23 Jan 2006 by mariachi v0.52