|
From: Chris W. <ch...@cw...> - 2002-01-22 12:30:19
|
On Tue, 2002-01-22 at 02:08, Chris McDaniel wrote:
>
> Hello,
>
> Looking over this code, I'm noticing that it's awfully messy, but I'm hoping
> someone can help me out. In the code below is the save routine from the
> package I'm working on. It branches near the end for new records and
> updates. Anyway, the save works in the case of a new record, but not an
> update. The only error I get is:
>
> Can't call method "save" on unblessed reference at
> /var/www/testsite/pkg/monitoring-0.01/testsite/Handler/Monitoring.pm line
> 410.
With errors like this, the variable ($host in this case) was probably
initialized to something other than you think. Probably the best thing
to do is ensure:
- $R->host returns the class for your object
- $host is an object rather than just a hashref. (Data::Dumper can be
your best friend for this)
so add:
use Data::Dumper qw( Dumper );
at the top of your handler, then do something like:
# New
$R->scrib( 1, "Host class is [", $R->host, "] and ",
"host is: ", Dumper( $host ) );
# Existing
if ($apr->param("delete".$i) eq "yes") {
$host->remove({DEBUG => 5});
} else {
$host->save({DEBUG => 5});
}
As long as your server is set to debugging level 1 or above. Hopefully
the results will be illuminating.
Chris
--
Chris Winters (ch...@cw...)
Building enterprise-capable snack solutions since 1988.
|