1 package Maypole::Application;
5 use UNIVERSAL::require;
10 our $VERSION = '2.09';
13 my ( $class, @plugins ) = @_;
14 my $caller = caller(0);
20 if (/^\-Setup$/) { $autosetup++; }
23 *{"$caller\::debug"} = sub { 1 };
24 warn "Debugging enabled";
26 elsif (/^-.*$/) { warn "Unknown flag: $_" }
28 my $plugin = "Maypole::Plugin::$_";
29 if ($plugin->require) {
30 push @plugin_modules, "Maypole::Plugin::$_";
31 warn "Loaded plugin: $plugin"
32 if $caller->can('debug') && $caller->debug;
34 warn qq(Loading plugin "$plugin" failed: )
35 . $UNIVERSAL::require::ERROR;
41 push @{"${caller}::ISA"}, @plugin_modules, $class;
42 $caller->config(Maypole::Config->new);
43 $caller->setup() if $autosetup;
46 if ( $ENV{MOD_PERL} ) {
47 Apache::MVC->require or die "Loading Apache frontend failed: $@";
48 push @ISA, 'Apache::MVC';
51 CGI::Maypole->require or die "Loading CGI frontend failed: $@";
52 push @ISA, 'CGI::Maypole';
59 Maypole::Application - Universal Maypole Frontend
63 use Maypole::Application;
65 use Maypole::Application qw(Config::YAML);
67 use Maypole::Application qw(-Debug Config::YAML -Setup);
69 use Maypole::Application qw(Config::YAML Loader -Setup -Debug);
73 This is a universal frontend for mod_perl1, mod_perl2 and CGI.
75 You can omit the Maypole::Plugin:: prefix from plugins.
76 So Maypole::Plugin::Config::YAML becomes Config::YAML.
78 use Maypole::Application qw(Config::YAML);
80 You can also set special flags like -Setup and -Debug.
82 use Maypole::Application qw(-Debug Config::YAML -Setup);
84 The position of plugins and flags in the chain is important,
85 because they are loaded/executed in the same order they appear.
89 use Maypole::Application qw(-Setup);
93 use Maypole::Application;
96 Note that no options are passed to C<setup()>. You must ensure that the
97 required model config parameters are set in C<MyApp-E<gt>config>. See
98 L<Maypole::Config> for more information.
102 use Maypole::Application qw(-Debug);
106 use Maypole::Application;
111 Sebastian Riedel, C<sri@oook.de>
112 Idea by Marcus Ramberg, C<marcus@thefeed.no>
116 You may distribute this code under the same terms as Perl itself.