1Maypole::Model::Base(3)User Contributed Perl DocumentatioMnaypole::Model::Base(3)
2
3
4

NAME

6       Maypole::Model::Base - Base class for model classes
7

DESCRIPTION

9       This is the base class for Maypole data models. This is an abstract
10       class that defines the interface, and can't be used directly.
11
12   process
13       This is the engine of this module. Given the request object, it
14       populates all the relevant variables and calls the requested action.
15
16       Anyone subclassing this for a different database abstraction mechanism
17       needs to provide the following methods:
18
19   setup_database
20           $model->setup_database($config, $namespace, @data)
21
22       Uses the user-defined data in @data to specify a database- for example,
23       by passing in a DSN. The model class should open the database, and
24       create a class for each table in the database. These classes will then
25       be "adopt"ed. It should also populate "$config->tables" and
26       "$config->classes" with the names of the classes and tables
27       respectively. The classes should be placed under the specified
28       namespace. For instance, "beer" should be mapped to the class
29       "BeerDB::Beer".
30
31   class_of
32           $model->class_of($r, $table)
33
34       This maps between a table name and its associated class.
35
36   fetch_objects
37       This class method is passed a request object and is expected to return
38       an object of the appropriate table class from information stored in the
39       request object.
40
41   adopt
42       This class method is passed the name of a model class that represensts
43       a table and allows the master model class to do any set-up required.
44
45   columns
46       This is a list of all the columns in a table. You may also override see
47       also "display_columns"
48
49   table
50       This is the name of the table.
51
52   Actions
53       do_edit
54           If there is an object in "$r->objects", then it should be edited
55           with the parameters in "$r->params"; otherwise, a new object should
56           be created with those parameters, and put back into "$r->objects".
57           The template should be changed to "view", or "edit" if there were
58           any errors. A hash of errors will be passed to the template.
59
60       list
61           The "list" method should fill "$r->objects" with all of the objects
62           in the class. You may want to page this using "Data::Page" or
63           similar.
64
65       edit
66           Empty Action.
67
68       view
69           Empty Action.
70
71       index
72           Empty Action, calls list if provided with a table.
73
74       Also, see the exported commands in "Maypole::Model::CDBI".
75

Other overrides

77       Additionally, individual derived model classes may want to override the
78       following methods:
79
80   display_columns
81       Returns a list of columns to display in the model. By default returns
82       all columns in alphabetical order. Override this in base classes to
83       change ordering, or elect not to show columns.
84
85   list_columns
86       Same as display_columns, only for listings. Defaults to display_columns
87
88   column_names
89       Return a hash mapping column names with human-readable equivalents.
90
91   is_public
92       should return true if a certain action is supported, or false
93       otherwise.  Defaults to checking if the sub has the ":Exported"
94       attribute.
95
96   add_model_superclass
97       Adds model as superclass to model classes (if necessary)
98
99   method_attrs
100       Returns the list of attributes defined for a method. Maypole itself
101       only defines the "Exported" attribute.
102
103   related
104       This can go either in the master model class or in the individual
105       classes, and returns a list of has-many accessors. A brewery has many
106       beers, so "BeerDB::Brewery" needs to return "beers".
107

SEE ALSO

109       Maypole, Maypole::Model::CDBI.
110

AUTHOR

112       Maypole is currently maintained by Aaron Trevena.
113

AUTHOR EMERITUS

115       Simon Cozens, "simon#cpan.org"
116
117       Simon Flack maintained Maypole from 2.05 to 2.09
118
119       Sebastian Riedel, "sri#oook.de" maintained Maypole from 1.99_01 to 2.04
120

LICENSE

122       You may distribute this code under the same terms as Perl itself.
123
124
125
126perl v5.32.0                      2020-07-28           Maypole::Model::Base(3)
Impressum