[Maypole] Maypole model inheritance

Dave Howorth Dave.Howorth@acm.org
Sun, 12 Dec 2004 16:10:16 +0000


Dave Howorth wrote:
> The difficulty here is that it's C-DBI-Loader that makes 
> MyApp::Model::Table inherit directly from Class::DBI::$driver. So to 
> make this work, you have to rewrite C-DBI-Loader, I think? Which seems 
> odd, since the scenario (using C-DBI-Loader to set up the table classes 
> but also wanting to use other C-DBI-* modules) is pure C-DBI, no 
> Maypole, so there ought to be an existing solution out there somewhere.

I did a little browsing around CDBI and found what may be a possibility. 
I looked at AutoLoader 
<http://search.cpan.org/~ryanparr/Class-DBI-AutoLoader-0.12/AutoLoader.pm> 
to see what it did and discovered two interesting features:

(1) It has a specific mechanism for loading additional classes:

  use Class::DBI::AutoLoader (
         ...
         additional_packages => ['Class::DBI::AbstractSearch']
  );

(2) It has a method of playing base class switcheroo using this package 
specifically designed for the purpose:

<http://search.cpan.org/~rclamp/Class-DBI-BaseDSN-1.22/lib/Class/DBI/BaseDSN.pm>

Food for thought.

Cheers, Dave