calling methods on deserialized objects
- From: "Michael Küper" <somone@xxxxxxxxx>
- Date: Fri, 25 Aug 2006 22:32:31 +0200
Hello Perl Specialists,
i'm struggling with a weird problem ....
background:
I have stored an "object tree" in a CGI::Session. I want to make the whole
object model persistent, when the page has finished rendering and restore
all the stuff when the page is loaded by a new request. So far so good: The
object structure seems to be serialized correct. When looking at the
structure with Data::Dumper before and after the
serialization/deserialization step, I can see no difference. Even the
blessing and backpointers in the structure are maintained. But anyway an
error occurs when trying to call methods on the deserialzed objects.
problem:
I have a "restored" object like:
my $page = $session->param{page};
now I want to iterate through the child controls and call a method on them:
foreach my $controlName (keys (%{$page->{mControls}}))
{
my $childControl = $page->{mControls}->{$controlName };
$childControl->load(); # i've checked that $childControl is a valid
blessed reference at this point!
}
The "$childControl->load();" statement causes the following error:
"can't locate object method "load" via package SMDplus::Web::Controls::Form
As the error also shows, perl is well aware of the class where the load
method is implemented. Unfortunately it says that the package doesn't
contain the "load" method (which is not the case).
I can achieve what I want by transforming the statement
$childControl->load(); # generates error
into:
my $class = ref($childControl);
eval("$class\:\:load(\$childControl)"); # works fine
Since I don't want to use eval for several reasons, I am looking for a way
to make the "intuitive syntax" work. I should say that i'm using
"inheritance" as well.... I'm very confused about this behaviour and also
have the bad feeling, that I didn't understand some fundamentals of perl
"objects" :-(.
Can anybody please enlight me? This problem drives me mad by the time ...
kind regards
Michael
.
- Follow-Ups:
- Re: calling methods on deserialized objects
- From: Mumia W.
- Re: calling methods on deserialized objects
- Prev by Date: Help with Net::SSH::Perl
- Next by Date: Re: calling methods on deserialized objects
- Previous by thread: Help with Net::SSH::Perl
- Next by thread: Re: calling methods on deserialized objects
- Index(es):
Relevant Pages
|