Skip Menu |

This queue is for tickets about the Maypole CPAN distribution.

Report information
The Basics
Id: 16977
Status: resolved
Priority: 0/
Queue: Maypole

People
Owner: TEEJAY [...] cpan.org
Requestors: aaron.trevena [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 2.10
Fixed in:
  • 2.11
  • 2.11_pre1
  • 2.11_pre2
  • 2.11_pre3
  • 2.11_pre5



Subject: using plain CDBI classes in Maypole
When you have a bunch of plain Class::DBI classes that you want to build your maypole application from, using Maypole::Model::CDBI::Plain won't work without inheriting it in your plain Class::DBI classes. You can fix this by replaining Maypole/Model/CDBI/Plain.pm with the attached Plain.pm module attached, or upgrading to SVN, or upgrading to 2.11 when it is released.
package Maypole::Model::CDBI::Plain; use Maypole::Config; use base 'Maypole::Model::CDBI'; use strict; Maypole::Config->mk_accessors(qw(table_to_class)); sub setup_database { my ( $self, $config, $namespace, $classes ) = @_; $config->{classes} = $classes; foreach my $class (@$classes) { if ( $class->require ) { warn "Loaded external module for '$class'\n" if $namespace->debug > 1; } else { (my $filename = $class) =~ s!::!/!g; die "Loading '$class' failed: $@\n" unless $@ =~ /Can\'t locate \Q$filename\E\.pm/; warn "No external module for '$class'" if $namespace->debug > 1; } } $config->{table_to_class} = { map { $_->table => $_ } @$classes }; $config->{tables} = [ keys %{ $config->{table_to_class} } ]; } sub class_of { my ( $self, $r, $table ) = @_; return $r->config->{table_to_class}->{$table}; } 1; =head1 NAME Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader =head1 SYNOPSIS package Foo; use 'Maypole::Application'; Foo->config->model("Maypole::Model::CDBI::Plain"); Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]); =head1 DESCRIPTION This module allows you to use Maypole with previously set-up L<Class::DBI> classes; simply call C<setup> with a list reference of the classes you're going to use, and Maypole will work out the tables and set up the inheritance relationships as normal. =head1 METHODS =over 4 =item setup_database =item class_of =back See L<Maypole::Model::Base> =cut