]> git.decadent.org.uk Git - maypole.git/blob - lib/Maypole/Config.pm
3307f8f5b650547145370c48170ff7b42ea2a403
[maypole.git] / lib / Maypole / Config.pm
1 package Maypole::Config;
2 use base qw(Class::Accessor::Fast);
3 use attributes ();
4
5 use strict;
6 use warnings;
7
8 our $VERSION = "1." . sprintf "%04d", q$Rev$ =~ /: (\d+)/;
9
10 # Public accessors.
11 __PACKAGE__->mk_accessors(
12      qw( view view_options uri_base template_root template_extension model
13          loader display_tables ok_tables rows_per_page dsn user pass opts
14          application_name additional build_form_elements)
15 );
16
17 # Should only be modified by model.
18 __PACKAGE__->mk_ro_accessors(qw( classes tables));
19
20 1;
21
22 =head1 NAME
23
24 Maypole::Config - Maypole Configuration Class
25
26 =head1 DESCRIPTION
27
28 This class stores all configuration data for your Maypole application.
29
30 =head1 METHODS
31
32 =head2 View related
33
34 =head3 application_name
35
36 This should be a string containing your application's name.
37
38 Optional. Is used in the factory templates.
39
40 =head3 rows_per_page
41
42 This is the number of rows your application should display per page.
43
44 Optional.
45
46 =head3 tables
47
48 Contains a list of all tables, if supported by model.
49
50 =head3 template_extension
51
52 Optional template file extension.
53
54 =head3 template_root
55
56 This is where your application can find its templates.
57
58 =head3 uri_base
59
60 This is the URI base that should be prepended to your application when Maypole
61 makes URLs.
62
63 =head3 view
64
65 The name of the view class for your Maypole Application. Defaults to
66 "Maypole::View::TT".
67
68 =head3 build_form_elements
69
70 Globally specify whether to build form elements; populating the cgi metadata with 
71 autogenerated HTML::Element widgets for the class/object.
72
73 Can be over-ridden per action using the method of the same name for the request.
74
75 If not set, then Maypole will assume it is true.
76
77 =head3 view_options
78
79 A hash of configuration options for the view class. Consult the documentation
80 for your chosen view class for information on available configuration options.
81
82 =head2 Model-Related
83
84 =head3 classes
85
86 This config variable contains a list of your view classes. This is set
87 up by the
88 model class, and should not be changed in the view or the config.
89
90 =head3 display_tables
91
92 This is a list of the tables that are public to your Maypole 
93 application. Defaults to all the tables in the database.
94
95 =head3 dsn
96
97 The DSN to your database. Follows standard DBD syntax.
98
99 =head3 loader
100
101 This is the loader object (n.b. an instance, not a class name). It's set
102 up by the CDBI model to an instance of "Class::DBI::Loader" if it's not
103 initialized before calling setup().
104
105 =head3 model
106
107 The name of the model class for your Maypole Application. Defaults to
108 "Maypole::Model::CDBI".
109
110 =head3 ok_tables
111
112 This is a hash of the public tables. It is populated automatically by 
113 Maypole from the list in display_tables and should not be changed.
114
115 =head3 pass
116
117 Password for database user.
118
119 =head3 opts
120
121 Other options to the DBI connect call.
122
123 =head3 user
124
125 Username to log into the database with.
126
127 =head2 Adding additional configuration data
128
129 You can use the 'additional' attribute for stashing additional info, especially from additional_data method,
130 i.e. $r->config->additional({foo=>bar});
131
132 Or..
133
134 If your modules need to store additional configuration data for their 
135 own use or to make available to templates, add a line like this to your 
136 module:
137
138    Maypole::Config->mk_accessors(qw(variable or variables));
139
140 Care is needed to avoid conflicting variable names.
141
142 =head1 SEE ALSO
143
144 L<Maypole>
145
146 =head1 AUTHOR
147
148 Sebastian Riedel, C<sri@oook.de>
149
150 =head1 AUTHOR EMERITUS
151
152 Simon Cozens, C<simon@cpan.org>
153
154 =head1 LICENSE
155
156 You may distribute this code under the same terms as Perl itself.
157
158 =cut
159