Inheritance problem

[prev] [thread] [next] [Date index for 2005/01/18]

From: Aleksandr Guidrevitch
Subject: Inheritance problem
Date: 11:21 on 18 Jan 2005
Hello All,

I'm struggling with some strange problem.

I have the following error message:
TAuction::Biz::Base::Lot can't load TAuction::Biz::User: 
TAuction::Biz::User can't load TAuction::Biz::Lot: Can't locate object 
method "__lot_extra" via package "TAuction::Biz::Lot" at 
../lib/TAuction/Biz/Lot.pm line 18.
Compilation failed in require at ../lib/Class/DBI.pm line 1211. at 
../lib/Class/DBI/Relationship/HasMany.pm line 20
Compilation failed in require at ../lib/Class/DBI.pm line 1211. at 
/home/ag/apps/perl-5.8.5/lib/site_perl/5.8.5/Class/DBI/Relationship/HasA.pm 
line 22
Compilation failed in require at (eval 2) line 3.
        ...propagated at /home/ag/apps/perl-5.8.5/lib/5.8.5/base.pm line 85.
BEGIN failed--compilation aborted at ../lib/TAuction/Biz/Lot/Delayed.pm 
line 6.


the files in question looks like:

-8<-------8<-------8<-------8<-------8<-------8<------
package TAuction::Biz::Base::Lot;
use base qw(TAuction::Class::DBI);
__PACKAGE__->columns(Primary => qw(id));
__PACKAGE__->columns(Essential => qw(owner_id...));
__PACKAGE__->has_a(owner_id    => 'TAuction::Biz::User');
....
__PACKAGE__->mk_classdata('__lot_extra'); # here it works ok

-8<-------8<-------8<-------8<-------8<-------8<------
package TAuction::Biz::Lot;
use base qw(TAuction::Biz::Base::Lot);
__PACKAGE__->table('lot');
__PACKAGE__->__lot_extra('TAuction::Biz::LotExtra');

-8<-------8<-------8<-------8<-------8<-------8<------
package TAuction::Biz::Lot::Delayed;
use base qw(TAuction::Biz::Base::Lot);
__PACKAGE__->table('lot_delayed');
__PACKAGE__->__lot_extra('TAuction::Biz::LotExtra::Delayed');

-8<-------8<-------8<-------8<-------8<-------8<------
package TAuction::Biz::User;
use base qw(TAuction::Class::DBI);
__PACKAGE__->table('user');
__PACKAGE__->columns(Primary => qw(id));
__PACKAGE__->has_many(lots => 'TAuction::Biz::Lot', 'owner_id');

-8<-------8<-------8<-------8<-------8<-------8<------

package TAuction::BackEnd::Lot::Open;
use TAuction::Biz::Lot::Delayed; # here it dies

Class::DBI -> TAuction::Class::DBI -> TAuction::Biz::Base::Lot -> 
TAuction::Biz::Lot
                                                              \-> 
TAuction::Biz::Lot

It looks like __PACKAGE__->mk_classdata('__lot_extra') in 
TAuction::Biz::Base::Lot doesn't get executed
since it isn't available in subclasses of TAuction::Biz::Base::Lot
(TAuction::Biz::Lot and TAuction::Biz::Lot::Delayed)

I've put 'use base qw(....)' on the top of each class, before all the 
other 'use's,
but it seems that __PACKAGE__->... are executed after all the 'use's are 
processed


Where can I read more an this issue ?
How can I work this around ? I suppose I need to write my own method for 
this purpose
instead of relying on Class::Data::Inheritable ?

Sincerely,
Aleksandr

Inheritance problem
Aleksandr Guidrevitch 11:21 on 18 Jan 2005

Re: Inheritance problem
Tony Bowden 11:23 on 18 Jan 2005

Generated at 17:42 on 27 Jan 2005 by mariachi v0.52