I see. I have followed that to the best I can,
and I am looking deeper into the PObject code.
Actually the save() method does seem to be here after all. Doing a class listing with stvns* recursing class lister I get,
MyHuman
-------------------------------------------
humanthingysub
myStorableBase
-------------------------------------------
name
phone
pobject
email
parentthingysub
id
Class::PObject::Template
-------------------------------------------
errstr
remove
__props
save
logtrc
new
load
fetch
count
confess
()
columns
dump
remove_all
(""
get
set
logconfig
__driver
croak
carp
drop_datasource
I've labelled human and parent thingies which are markers for methods in places I want to extend. So, we do inherit from ::Template and we get save() into the bargain, but unlike using an instance at the top level which saves and loads just fine I get a runtime error (which I've been seeing as a missing save() all along). Something else is up...OK, the context of use is,
#!/usr/bin/perl
use MyHuman;
my $person = MyHuman->new();
$person->name('bob');
$person->email('bob@bob.com');
$new_id = $person->save() or die "save bork";
my $newperson = MyHuman->load($new_id) or die "reload bork";;
print "reload OK\nname is: ".$person->name()."\n";
..and we get a runtime,
Can't locate Class/PObject/Driver/.pm in @INC...
So my understanding is that its creating an instance just fine.Somehow the definition of the db_file and path are getting lost?
___________________________
*
A little while back another monk posted a very useful tool
which has been invaluable to me experimenting with more
adventurous OO Perl. I can't find the link, even in the
supersearch, so I've posted the code again below. Note where
I am using this to explore the inheritance of class myHuman.
#!/usr/bin/perl
use strict;
use warnings;
no strict 'refs';
=pod
# Class/Object Method Lister
# on Jan 18, 2004 at 21:03 = by stvn
# if you want certain methods ignored,
# put their names in this string
=cut
my $IGNORE = "";
require MyHuman;
printFlatClassView("MyHuman");
print "\n";
printExpandedClassView("MyHuman");
print "\n";
## ------------------------------------------------------------------
sub getClassMethodList {
my $class = shift;
return grep {
!/^($IGNORE)$/ && defined &{"${class}::$_"}
} keys %{"${class}::"};
}
## ------------------------------------------------------------------
sub getCompleteClassMethodList {
my ($class) = @_;
my @methods = getClassMethodList($class);
push @methods => map {
getCompleteClassMethodList($_)
} @{"${class}::ISA"};
return @methods;
}
## ------------------------------------------------------------------
sub printExpandedClassView {
my ($class, $tab_count) = @_;
$tab_count ||= 0;
if ($tab_count) {
my $t = ("\t" x $tab_count);
print "${t}$class\n";
print "${t}-------------------------------------------\n$t";
print join "\n${t}", getClassMethodList($class);
print "\n";
}
else {
print("$class\n");
print "-------------------------------------------\n";
print join "\n" => getClassMethodList($class);
print "\n";
}
map {
printExpandedClassView($_, $tab_count + 1)
} @{"${class}::ISA"};
}
sub printFlatClassView {
my ($class) = @_;
print("$class\n");
print "-------------------------------------------\n";
my %method = map {
$_ => 1
} getCompleteClassMethodList($class);
print join "\n" => keys %method;
print "\n";
}
## ------------------------------------------------------------------
1;
I've retititled more approppriately. I do appreciate all your help with this.
Andy. |