Maypole...DBI::DFV(3)

πŸ“¦
version 2.13 Β· 2 versions
, in fedora 43

Maypole::Model::CDBI::DFV πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation section of the manual, and it's all about Maypole::Model::CDBI::DFV β€” the Class::DBI::DFV model for Maypole. yes we're doing old-school Perl web frameworks today and honestly? iconic. πŸŽ€


✨ NAME ✨

Maypole::Model::CDBI::DFV β€” it's the Class::DBI::DFV model for Maypole. that's the whole name, periodt. πŸ’…


🌸 SYNOPSIS 🌸

like here's the whole vibe, look:

package Foo;
use 'Maypole::Application';

Foo->config->model("Maypole::Model::CDBI::DFV");
Foo->setup([qw/ Foo::SomeTable Foo::Other::Table /]);

# Look ma, no untainting

sub Foo::SomeTable::SomeAction : Exported {

    . . .

}

look ma, no untainting β€” the comment is literally in the source and honestly it's giving main character energy. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so this module is the glow-up that lets you use Maypole with Class::DBI classes you already set up that use Class::DBI::DFV. no cap.

all you gotta do is call setup with a list reference of the classes you're gonna use, and Maypole will work out the tables and set up all the inheritance relationships as normal. she just knows. 🧚

and better still?? it will also use your DFV profile to validate input instead of CGI::Untaint. for teh win!! πŸ† (the original really does say "teh win" and we respect the heritage)


πŸ‘‘ METHODS πŸ‘‘

setup

this method is inherited from Maypole::Model::Base, and it calls setup_database, which uses Class::DBI::Loader to create and load Class::DBI classes from the given database schema. chain of command, love to see it. ✨

setup_database

this method loads the model classes for the application. that's it. that's the job. πŸŽ€

class_of

returns the class for a given table. short, sweet, slay. πŸ’–

adopt

this class method gets passed the name of a model class that represents a table, and it lets the master model class do any set-up that's required. like a mom adopting a whole table, metaphorically. πŸ™ˆ

check_params

checks parameters against the DFV profile for the class, and returns the results of DFV's check. here's how you'd call it:

my $dfv_results = __PACKAGE__->check_params($r->params);

validation queen πŸ‘‘


🌈 Action Methods 🌈

okay so action methods are methods that you access through the web (or any other public) interface. they're the ones with main character energy, the ones the people actually see. ⭐

these are inherited from Maypole::Model::CDBI::Base β€” except do_edit, which is down below, she's special. πŸ’…

do_edit

if there's an object in $r->objects, then it should be edited using the parameters in $r->params. otherwise, a brand new object gets created with those parameters, and gets put back into $r->objects. the template should be changed to view, or to edit if there were any errors. and a hash of errors gets passed to the template so everyone knows what went down. 😭

do_delete

inherited from Maypole::Model::CDBI::Base.

this action deletes records. dramatic. final. iconic. πŸ’€

inherited from Maypole::Model::CDBI::Base.

this action method searches for database records. detective mode activated πŸ”

list

inherited from Maypole::Model::CDBI::Base.

the list method fills $r->objects with all of the objects in the class. the results are paged using a pager, because we are not rendering ten thousand rows at once, bestie, we have standards. ✨


πŸŽ€ SEE ALSO πŸŽ€

  • Maypole::Model::Base
  • Maypole::Model::CDBI::Base

go read those too, iykyk 🫢


πŸ’œ AUTHOR πŸ’œ

Aaron Trevena. πŸ’–


⭐ LICENSE ⭐

you may distribute this code under the same terms as Perl itself. free to share, free to love, fr fr. 🌸


and that's the whole page bestie!! this was rendered by perl v5.42.0 and dated 2025-07-25 β€” go forth and Maypole responsibly. mwah πŸ’‹ πŸ¦‹
πŸ“¦ where this page comes from