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.
38 use base 'Maypole::Model::CDBI::Base';
40 use Maypole::Model::CDBI::AsForm;
41 use Maypole::Model::CDBI::FromCGI;
42 use CGI::Untaint::Maypole;
48 Action methods are methods that are accessed through web (or other public) interface.
50 Inherited from L<Maypole::Model::CDBI::Base>
54 If there is an object in C<$r-E<gt>objects>, then it should be edited
55 with the parameters in C<$r-E<gt>params>; otherwise, a new object should
56 be created with those parameters, and put back into C<$r-E<gt>objects>.
57 The template should be changed to C<view>, or C<edit> if there were any
58 errors. A hash of errors will be passed to the template.
62 Inherited from Maypole::Model::CDBI::Base.
64 This action deletes records
68 Inherited from Maypole::Model::CDBI::Base.
70 This action method searches for database records.
74 Inherited from Maypole::Model::CDBI::Base.
76 The C<list> method fills C<$r-E<gt>objects> with all of the
77 objects in the class. The results are paged using a pager.
83 Set the class you use to untaint and validate form data
84 Note it must be of type CGI::Untaint::Maypole (takes $r arg) or CGI::Untaint
88 sub Untainter { 'CGI::Untaint::Maypole' };
92 This method is inherited from Maypole::Model::Base and calls setup_database,
93 which uses Class::DBI::Loader to create and load Class::DBI classes from
94 the given database schema.
98 This method loads the model classes for the application
103 my ( $self, $config, $namespace, $classes ) = @_;
104 $config->{classes} = $classes;
105 foreach my $class (@$classes) { $namespace->load_model_subclass($class); }
106 $namespace->model_classes_loaded(1);
107 $config->{table_to_class} = { map { $_->table => $_ } @$classes };
108 $config->{tables} = [ keys %{ $config->{table_to_class} } ];
113 returns class for given table
118 my ( $self, $r, $table ) = @_;
119 return $r->config->{table_to_class}->{$table};
124 This class method is passed the name of a model class that represensts a table
125 and allows the master model class to do any set-up required.
130 my ( $self, $child ) = @_;
131 if ( my $col = $child->stringify_column ) {
132 $child->columns( Stringify => $col );
138 L<Maypole::Model::Base>
140 L<Maypole::Model::CDBI>