> So that's why Class::DBI::mysql ends up behind Class::DBI in the
> inheritance and in consequence the wrong version of column_type gets
> called.
I've done a bit more digging and definitely believe this is a bug now.
Maypole::Model::CDBI sets itself up with the wrong inheritance graph.
Just as a reminder of the starting point, the CDBI::mysql docs say to
inherit from that rather than CDBI itself, if its a MySQL database. The
symptoms that Peter and myself see are that when you call column_type,
you see CDBI's deprecation warning instead of accessing CDBI::mysql's
version.
So I did an experiment. I hacked Maypole/Model/CDBI.pm to change its
inheritance. There's a patch below; I stress this is not a proposed fix
for the bug, just a demonstration of removing the failure mechanism.
Basically all I wanted to do is remove Class::DBI from M-M-CDBI's @ISA
so the inheritance set up by Class::DBI::Loader::mysql takes full
effect. I needed to knock out the use CDBI::* statements because they
can't execute until the appropriate model is loaded. Then I needed to
patch M-M-CDBI's @ISA afterwards, once the loader had done it's stuff.
This is enough to run the frontpage with the revised class hierarchy.
It's late and I'm going to bed now :)
It needs a clearer mind to think about a proper patch.
Cheers, Dave
--- Maypole/Model/CDBI.pm original
+++ Maypole/Model/CDBI.pm modified
@@ -1,11 +1,13 @@
package Maypole::Model::CDBI;
-use base qw(Maypole::Model::Base Class::DBI);
-use Class::DBI::AsForm;
+use base qw(Maypole::Model::Base); # djh 2004-12-11 : remove Class::DBI
+#use Class::DBI::AsForm;
use Class::DBI::FromCGI;
use Class::DBI::Loader;
-use Class::DBI::AbstractSearch;
-use Class::DBI::Plugin::RetrieveAll;
-use Class::DBI::Pager;
+#use Class::DBI::AbstractSearch;
+#use Class::DBI::Plugin::RetrieveAll;
+#use Class::DBI::Pager;
+
+print STDERR "Modified Maypole::Model::CDBI without Class::DBI base\n";
use Lingua::EN::Inflect::Number qw(to_PL);
use CGI::Untaint;
@@ -226,6 +228,14 @@
$config->{tables} = [ $config->{loader}->tables ];
warn( 'Loaded tables: ' . join ',', @{ $config->{tables} } )
if $namespace->debug;
+# djh - inherit the appropriate CDBI model class from a 'subclass'
+my $any_subclass = $config->{classes}->[0];
+no strict 'refs';
+my @isa = @{"$any_subclass\::ISA"};
+print STDERR "subclass isa=", join ', ', @isa, "\n";
+push @{"$self\::ISA"}, @isa;
+print STDERR "main class isa=", join ', ', @{"$self\::ISA"}, "\n";
+ # safe to load CDBI::* modules now we've inherited from CDBI flavour
}
sub class_of {
_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole
This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:57 GMT