in reply to Inheritance and objects tied to a database

I could be barking up the wrong tree completely here, but isn't it possible to do something like

# Parent is the name of the package containing DESTROY $self->Parent::DESTROY;

to call the parent class's DESTROY method over the child's?

I'm not an OO expert, especially not with Perl, so I could be totally wrong, but that's how it works with proceedural Perl if you override, say, exit, and then need to call the core exit routine.

Hope that helps (if it works ..)
-- Foxcub

Replies are listed 'Best First'.
Re: Re: Inheritance and objects tied to a database
by relax99 (Monk) on Dec 20, 2002 at 12:41 UTC

    I tried it and, unless I made some kind of fundamental mistake in my test, it doesn't work. I think when you do something like  $self->Parent::DESTROY(); it just uses the parent's DESTROY() method with child's data. So yes, it would save the changes to the database, but they are going to be almost instantly overwritten with parent's data when the parent's DESTROY() method is executed.

    Thanks for trying to help! I'm still confused about the issue though.

      I guess the alternative would be to take the save out of DESTROY, and explicitly save the data to the DB ..?

      That way, a call to, say, $self->Parent::Save would save using the child data, and you can simply bypass the save when the parent is destroyed.

      After all, if no changes are made in the child no save of the parental data should be needed anyway (if I'm reading this right).

      Just a thought ..
      -- Foxcub

        I guess I could do that. It just feels like it's a workaround only applied for the (my) lack of understanding of how to do it correctly with tie() and the inheritance mechanism.