1 package Maypole::Model::CDBI::Plain;
6 Maypole::Model::CDBI::Plain - Class::DBI model without ::Loader
11 use 'Maypole::Application';
13 Foo->config->model("Maypole::Model::CDBI::Plain");
14 Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);
16 # untaint columns and provide custom actions for each class
18 Foo::SomeTable->untaint_columns(email => ['email'], printable => [qw/name description/]);
20 Foo::Other::Table->untaint_columns ( ... );
22 sub Foo::SomeTable::SomeAction : Exported {
30 This module allows you to use Maypole with previously set-up
31 L<Class::DBI> classes; simply call C<setup> with a list reference
32 of the classes you're going to use, and Maypole will work out the
33 tables and set up the inheritance relationships as normal.
39 use base 'Maypole::Model::CDBI::Base';
41 use Maypole::Model::CDBI::AsForm;
42 use Maypole::Model::CDBI::FromCGI;
43 use CGI::Untaint::Maypole;
49 Action methods are methods that are accessed through web (or other public) interface.
51 Inherited from L<Maypole::Model::CDBI::Base>
55 If there is an object in C<$r-E<gt>objects>, then it should be edited
56 with the parameters in C<$r-E<gt>params>; otherwise, a new object should
57 be created with those parameters, and put back into C<$r-E<gt>objects>.
58 The template should be changed to C<view>, or C<edit> if there were any
59 errors. A hash of errors will be passed to the template.
63 Inherited from Maypole::Model::CDBI::Base.
65 This action deletes records
69 Inherited from Maypole::Model::CDBI::Base.
71 This action method searches for database records.
75 Inherited from Maypole::Model::CDBI::Base.
77 The C<list> method fills C<$r-E<gt>objects> with all of the
78 objects in the class. The results are paged using a pager.
84 Set the class you use to untaint and validate form data
85 Note it must be of type CGI::Untaint::Maypole (takes $r arg) or CGI::Untaint
89 sub Untainter { 'CGI::Untaint::Maypole' };
93 This method is inherited from Maypole::Model::Base and calls setup_database,
94 which uses Class::DBI::Loader to create and load Class::DBI classes from
95 the given database schema.
99 This method loads the model classes for the application
104 my ( $self, $config, $namespace, $classes ) = @_;
105 $config->{classes} = $classes;
106 foreach my $class (@$classes) { $namespace->load_model_subclass($class); }
107 $namespace->model_classes_loaded(1);
108 $config->{table_to_class} = { map { $_->table => $_ } @$classes };
109 $config->{tables} = [ keys %{ $config->{table_to_class} } ];
114 returns class for given table
119 my ( $self, $r, $table ) = @_;
120 return $r->config->{table_to_class}->{$table};
125 This class method is passed the name of a model class that represensts a table
126 and allows the master model class to do any set-up required.
131 my ( $self, $child ) = @_;
132 if ( my $col = $child->stringify_column ) {
133 $child->columns( Stringify => $col );
139 L<Maypole::Model::Base>
141 L<Maypole::Model::CDBI>