1 package Maypole::Application;
5 use UNIVERSAL::require;
8 # funny little gimmick ;)
11 | \/ | __ _ _ _ _ __ ___ | | ___
12 | |\/| |/ _` | | | | '_ \ / _ \| |/ _ \
13 | | | | (_| | |_| | |_) | (_) | | __/
14 |_| |_|\__,_|\__, | .__/ \___/|_|\___|
15 |___/|_| -= VERSION =-
17 $banner =~ s/VERSION/$Maypole::VERSION/;
23 my ( $self, @plugins ) = @_;
24 my $caller = caller(0);
26 push @{"${caller}::ISA"}, $self;
28 if (/^\-Setup$/) { $caller->setup }
30 *{"$caller\::debug"} = sub { 1 };
31 warn "Debugging enabled";
35 # The plugin caller should be our application class
36 eval "package $caller; require Maypole::Plugin::$_";
37 if ($@) { warn qq(Loading plugin "Maypole::Plugin::$_" failed: $@) }
39 warn "Loaded plugin: Maypole::Plugin::$_" if $caller->debug;
40 unshift @ISA, "Maypole::Plugin::$_";
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 - Maypole Universal 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;
98 use Maypole::Application qw(-Debug);
102 use Maypole::Application;
107 Sebastian Riedel, C<sri@oook.de>
108 Idea by Marcus Ramberg, C<marcus@thefeed.no>
112 You may distribute this code under the same terms as Perl itself.