[Dbix-class] using load_classes selectively

Frazer Irving clumsyjedi at gmail.com
Thu Feb 7 16:39:05 GMT 2008


Hi everybody,

I'm a first time poster to this list. I hope I have the right place to ask
this question.

I am currently in the process of setting up DBIx::Class as the ORM for my
employer. I have setup the basic structure as so...

package My::DB;
use base qw/DBIx::Class::Schema/;
__Package__->load_classes();

package My::AbstractClass;
use base qw(DBIx::Class);

package My::DB::Foo;
use base qw(My::AbstractClass);
...
__PACKAGE__->belongs_to(bar =3D> 'My::DB::Bar');
__PACKAGE__->has_many(baz =3D> 'My::DB::Baz');

That all works great, but the load_classes method is called for every class
whenever I 'use My::DB'. I would like the classes to only load when I am
going to use them. I have experimented with moving the load_classes
definitions into My::DB::Foo etc, and only specifying the current
__PACKAGE__ and it's relationships but this results in all relationships for
My::DB::Foo being loaded when that class is loaded even if they are not
going to be used.

Is there some way I can load the relation classes only when a call is made
to the accessor for that relation? I have looked for an answer in the docs
and in the googles but to no avail.

Cheers

f
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20080207/a75=
8fc39/attachment.htm


More information about the DBIx-Class mailing list