From b747784007f4d0e718fcb5f98cf6f0d165c24982 Mon Sep 17 00:00:00 2001 From: Aaron Trevena Date: Wed, 29 Jun 2005 18:34:16 +0000 Subject: [PATCH] applied patch for http://rt.cpan.org/NoAuth/Bug.html?id=12383 git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@341 48953598-375a-da11-a14b-00016c27c3ee --- Changes | 3 ++- lib/Maypole/Application.pm | 42 ++++++++++++++++++++++++-------------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/Changes b/Changes index 1452fb6..f6d2946 100644 --- a/Changes +++ b/Changes @@ -2,9 +2,10 @@ This file documents the revision history for Perl extension Maypole. For information about current developments and future releases, see: http://maypole.perl.org/?TheRoadmap -2.10 July 2005 +2.10 Wed 29 Jun 2005 Multiple Template Paths added ( http://rt.cpan.org/NoAuth/Bug.html?id=13447 ) Small fix to templates/factory/frontpage ( http://rt.cpan.org/NoAuth/Bug.html?id=11236 ) + MasonX support in Maypole::Application ( https://rt.cpan.org/NoAuth/Bug.html?id=12383 ) 2.09 Mon Jan 25 22:00:00 2005 Fixes: diff --git a/lib/Maypole/Application.pm b/lib/Maypole/Application.pm index 4f61f42..0678adb 100644 --- a/lib/Maypole/Application.pm +++ b/lib/Maypole/Application.pm @@ -12,26 +12,42 @@ our $VERSION = '2.09'; sub import { my ( $class, @plugins ) = @_; my $caller = caller(0); + + my $frontend = 'Apache::MVC' if $ENV{MOD_PERL}; + + my $masonx; + if ( grep { /^MasonX$/ } @plugins ) + { + $masonx++; + @plugins = grep { ! /^MasonX$/ } @plugins; + $frontend = 'MasonX::Maypole'; + } + + $frontend ||= 'CGI::Maypole'; + + $frontend->require or die "Loading $frontend frontend failed: $@"; + push @ISA, $frontend; my $autosetup=0; my @plugin_modules; { foreach (@plugins) { if (/^\-Setup$/) { $autosetup++; } - elsif (/^\-Debug$/) { + elsif (/^\-Debug(\d*)$/) { + my $d = $1 || 1; no strict 'refs'; - *{"$caller\::debug"} = sub { 1 }; - warn "Debugging enabled"; + *{"$caller\::debug"} = sub { $d }; + warn "Debugging (level $d) enabled for $caller"; } elsif (/^-.*$/) { warn "Unknown flag: $_" } else { my $plugin = "Maypole::Plugin::$_"; if ($plugin->require) { push @plugin_modules, "Maypole::Plugin::$_"; - warn "Loaded plugin: $plugin" + warn "Loaded plugin: $plugin for $caller" if $caller->can('debug') && $caller->debug; } else { - warn qq(Loading plugin "$plugin" failed: ) + die qq(Loading plugin "$plugin" for $caller failed: ) . $UNIVERSAL::require::ERROR; } } @@ -40,18 +56,10 @@ sub import { no strict 'refs'; push @{"${caller}::ISA"}, @plugin_modules, $class; $caller->config(Maypole::Config->new); + $caller->config->masonx({}) if $masonx; $caller->setup() if $autosetup; } -if ( $ENV{MOD_PERL} ) { - Apache::MVC->require or die "Loading Apache frontend failed: $@"; - push @ISA, 'Apache::MVC'; -} -else { - CGI::Maypole->require or die "Loading CGI frontend failed: $@"; - push @ISA, 'CGI::Maypole'; -} - 1; =head1 NAME @@ -68,9 +76,11 @@ Maypole::Application - Universal Maypole Frontend use Maypole::Application qw(Config::YAML Loader -Setup -Debug); + use Maypole::Application qw(-Debug2 MasonX AutoUntaint); + =head1 DESCRIPTION -This is a universal frontend for mod_perl1, mod_perl2 and CGI. +This is a universal frontend for mod_perl1, mod_perl2, HTML::Mason and CGI. You can omit the Maypole::Plugin:: prefix from plugins. So Maypole::Plugin::Config::YAML becomes Config::YAML. @@ -106,6 +116,8 @@ is equivalent to use Maypole::Application; sub debug { 1 } +You can specify a higher debug level by saying C<-Debug2> etc. + =head1 AUTHOR Sebastian Riedel, C -- 2.39.5