1 package Maypole::Application;
5 use UNIVERSAL::require;
10 my ( $self, @plugins ) = @_;
11 my $caller = caller(0);
13 push @{"${caller}::ISA"}, $self;
15 if (/^\-Setup$/) { $caller->setup }
17 *{"$caller\::debug"} = sub { 1 };
18 warn "Debugging enabled";
22 # The plugin caller should be our application class
23 eval "package $caller; require Maypole::Plugin::$_";
24 if ($@) { warn qq(Loading plugin "Maypole::Plugin::$_" failed: $@) }
26 warn "Loaded plugin: Maypole::Plugin::$_" if $caller->debug;
27 unshift @ISA, "Maypole::Plugin::$_";
33 if ( $ENV{MOD_PERL} ) {
34 Apache::MVC->require or die "Loading Apache frontend failed: $@";
35 push @ISA, 'Apache::MVC';
38 CGI::Maypole->require or die "Loading CGI frontend failed: $@";
39 push @ISA, 'CGI::Maypole';
46 Maypole::Application - Maypole Universal Frontend
50 use Maypole::Application;
54 This is a universal frontend for mod_perl1, mod_perl2 and CGI.
56 You can omit the Maypole::Plugin:: prefix from plugins.
57 So Maypole::Plugin::Config::YAML becomes Config::YAML.
59 use Maypole::Application qw(Config::YAML);
61 You can also set special flags like -Setup and -Debug.
63 use Maypole::Application qw(-Debug Config::YAML -Setup);
65 The position of plugins and flags in the chain is important,
66 because they are loaded/executed in the same order they appear.
70 use Maypole::Application qw(-Setup);
74 use Maypole::Application;
79 use Maypole::Application qw(-Debug);
83 use Maypole::Application;
88 Sebastian Riedel, C<sri@oook.de>
89 Idea by Marcus Ramberg, C<marcus@thefeed.no>
93 You may distribute this code under the same terms as Perl itself.