Problems recreating an object?

[prev] [thread] [next] [Date index for 2005/06/05]

From: Lonely Rolling Star
Subject: Problems recreating an object?
Date: 00:29 on 05 Jun 2005
When I do this:

my $doomed = Film->create({ title => 'Doomed' });
$doomed->delete;
my $revive = Film->create({ title => 'Doomed' });

I get this error:
Can't locate object method "call_trigger" via package 
"Class::DBI::Object::Has::Been::Deleted" at 
/usr/local/share/perl/5.8.3/Class/DBI.pm line 579.

However, if I undef($doomed); before reviving it, I get no error.

I think this is an interaction with the Live_Objects hash. (I can 
also get rid of the error by calling Film->clear_object_index;)

It looks like delete is doing this:
     undef %$self;
     bless $self, 'Class::DBI::Object::Has::Been::Deleted';

... which leaves defined($self) true.

But this test is being done in _init:
     unless (defined($obj = $Live_Objects{$obj_key}))

... which succeeds.


It seems like either the Live_Objects entry should be removed in 
delete, or the test in _init should check to make sure ref($obj) 
isn't Class::DBI::Object::Has::Been::Deleted.


Here's a failing test case for 02-Film.t:

my $doomed = Film->create({ title => 'Doomed' });
$doomed->delete;
eval { my $revive = Film->create({ title => 'Doomed' }); };
ok (!$@, "no error recreating deleted object while still in scope");

        -- 
        Aneel Nazareth -- http://eye-of-newt.com/nazareth --

Problems recreating an object?
Lonely Rolling Star 00:29 on 05 Jun 2005

Re: Problems recreating an object?
Perrin Harkins 04:10 on 08 Jun 2005

Generated at 16:37 on 28 Jul 2005 by mariachi v0.52