1 package Maypole::Model::CDBI::DFV;
4 use base qw(Maypole::Model::Base);
7 Maypole::Config->mk_accessors(qw(table_to_class));
11 Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader
16 use 'Maypole::Application';
18 Foo->config->model("Maypole::Model::CDBI::DFV");
19 Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);
21 # Look ma, no untainting
23 sub Foo::SomeTable::SomeAction : Exported {
31 This module allows you to use Maypole with previously set-up
32 L<Class::DBI> classes that use Class::DBI::DFV;
34 Simply call C<setup> with a list reference of the classes you're going to use,
35 and Maypole will work out the tables and set up the inheritance relationships
38 Better still, it will also set use your DFV profile to validate input instead
39 of CGI::Untaint. For teh win!!
45 This method is inherited from Maypole::Model::Base and calls setup_database,
46 which uses Class::DBI::Loader to create and load Class::DBI classes from
47 the given database schema.
51 This method loads the model classes for the application
56 my ( $self, $config, $namespace, $classes ) = @_;
57 $config->{classes} = $classes;
58 foreach my $class (@$classes) { $namespace->load_model_subclass($class); }
59 $namespace->model_classes_loaded(1);
60 $config->{table_to_class} = { map { $_->table => $_ } @$classes };
61 $config->{tables} = [ keys %{ $config->{table_to_class} } ];
66 returns class for given table
71 my ( $self, $r, $table ) = @_;
72 return $r->config->{table_to_class}->{$table};
75 =head2 add_model_superclass
77 Adds model as superclass to model classes
81 sub add_model_superclass {
82 my ($class,$config) = @_;
83 foreach my $subclass ( @{ $config->classes } ) {
84 next if $subclass->isa("Maypole::Model::Base");
86 push @{ $subclass . "::ISA" }, $config->model;
93 This class method is passed the name of a model class that represensts a table
94 and allows the master model class to do any set-up required.
99 my ( $self, $child ) = @_;
100 if ( my $col = $child->stringify_column ) {
101 $child->columns( Stringify => $col );
107 L<Maypole::Model::Base>
109 L<Maypole::Model::CDBI>