in reply to Re: __PACKAGE__ in subclass
in thread __PACKAGE__ in subclass

Reading your reply, I realise that I missed out a key point. Very sorry. I was writing to the poop group too and assumed too much immersion in Class::DBI.

__PACKAGE__->has_many( 'sessions', 'Super::Session', 'person' );

The has_many() class method here creates two object methods: a sessions() method in this class, which returns a list of session objects, and a person() method in Super::Session, which returns a single person object. It's just a way of representing a one to many link.

As you say, everything is fine in the class and subclass presented here: you get what you ask for according to where you ask for it.

Where it breaks down is in the method created in the foreign class. It thinks it should return an object of Super::Person, since that was the package from which it was created, but in fact I want an object of Sub::Person, since that was the subclass which caused - but did not make - the call to has_many. grrr.

I'm beginning to think that Class::DBI's inheritance is just broken here. Or, as you say, my thinking is broken here. Guess I need to find another way.

Replies are listed 'Best First'.
Re^3: __PACKAGE__ in subclass
by Aristotle (Chancellor) on Oct 20, 2002 at 20:06 UTC
    I'm unsure as to what you're trying to do, but maybe the caller function would help you?

    Makeshifts last the longest.