1 package Maypole::Application;
5 use UNIVERSAL::require;
11 my ( $self, @plugins ) = @_;
12 my $caller = caller(0);
14 push @{"${caller}::ISA"}, $self;
16 if (/^\-Setup$/) { $caller->setup }
18 *{"$caller\::debug"} = sub { 1 };
19 warn "Debugging enabled";
21 elsif (/^-.*$/) { warn "Unknown flag: $_" }
24 # The plugin caller should be our application class
25 eval "package $caller; require Maypole::Plugin::$_";
26 if ($@) { warn qq(Loading plugin "Maypole::Plugin::$_" failed: $@) }
28 warn "Loaded plugin: Maypole::Plugin::$_" if $caller->debug;
29 unshift @ISA, "Maypole::Plugin::$_";
35 if ( $ENV{MOD_PERL} ) {
36 Apache::MVC->require or die "Loading Apache frontend failed: $@";
37 push @ISA, 'Apache::MVC';
40 CGI::Maypole->require or die "Loading CGI frontend failed: $@";
41 push @ISA, 'CGI::Maypole';
48 Maypole::Application - Maypole Universal Frontend
52 use Maypole::Application;
54 use Maypole::Application qw(Config::YAML);
56 use Maypole::Application qw(-Debug Config::YAML -Setup);
58 use Maypole::Application qw(Config::YAML Loader -Setup -Debug);
62 This is a universal frontend for mod_perl1, mod_perl2 and CGI.
64 You can omit the Maypole::Plugin:: prefix from plugins.
65 So Maypole::Plugin::Config::YAML becomes Config::YAML.
67 use Maypole::Application qw(Config::YAML);
69 You can also set special flags like -Setup and -Debug.
71 use Maypole::Application qw(-Debug Config::YAML -Setup);
73 The position of plugins and flags in the chain is important,
74 because they are loaded/executed in the same order they appear.
78 use Maypole::Application qw(-Setup);
82 use Maypole::Application;
87 use Maypole::Application qw(-Debug);
91 use Maypole::Application;
96 Sebastian Riedel, C<sri@oook.de>
97 Idea by Marcus Ramberg, C<marcus@thefeed.no>
101 You may distribute this code under the same terms as Perl itself.