Re: Using class::dbi::factory with multiple table classes in a single file

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

From: William Ross
Subject: Re: Using class::dbi::factory with multiple table classes in a single file
Date: 18:50 on 05 Apr 2005
On 5 Apr 2005, at 19:05, Barry Dancis wrote:

> Hi--
> =A0
> =A0=A0=A0 Is there a way to have the class::dbi subclass definitions =
all in=20
> the same file and=A0 use class::dbi::factory?
> If I place each subclass in its own file, factory works fine. If I=20
> collect them all into a single pm file, I get an error when I try to=20=

> get the colums
> =A0
> =A0=A0=A0 my @columns =3D $WebCams->columns ('assay');
> and the message is:
> =A0
> =A0=A0=A0 failed to load class 'Assay': Can't locate Assay.pm in @INC

The factory attempts to load data classes for you on startup. If you=20
don't want it to do that, and you're confident that the packages are=20
already loaded, you could override its load_class method with a simpler=20=

one that omits the require() step but still calls assimilate_class to=20
load the class data and post_require to drop the factory() method into=20=

each class:

sub load_class {
	my ($self, $class) =3D @_;
	return unless $class;
	my $moniker =3D $self->assimilate_class($class);
	$self->post_require($moniker, $class);
}

I can make this configurable in the next (imminent) version if that=20
seems like a good idea.

will

Re: Using class::dbi::factory with multiple table classes in a single file
William Ross 18:50 on 05 Apr 2005

Generated at 14:42 on 11 Apr 2005 by mariachi v0.52