From e4a0017ce9d93d1149b434da4869fb7a9bed746b Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Fri, 16 Apr 2010 09:06:40 -0500 Subject: [PATCH] move debug configuration into psgi --- lib/WebGUI/Middleware/Session.pm | 21 ++------------------- var/site.psgi | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/WebGUI/Middleware/Session.pm b/lib/WebGUI/Middleware/Session.pm index 15fbecd25..175790c6f 100644 --- a/lib/WebGUI/Middleware/Session.pm +++ b/lib/WebGUI/Middleware/Session.pm @@ -64,28 +64,11 @@ sub call { return [ 500, [ 'Content-Type' => 'text/plain' ], [ 'Internal Server Error' ] ]; } } - + # Perhaps I'm being paranoid.. weaken $session->{_config}; - my $debug = $self->canShowDebug($env); - if ($debug) { - $app = Plack::Middleware::StackTrace->wrap($app); - $app = Plack::Middleware::Debug->wrap( $app, - panels => [ - 'Environment', - 'Response', - 'Timer', - 'Memory', - 'Session', - 'PerlConfig', - [ 'MySQLTrace', skip_packages => qr/\AWebGUI::SQL(?:\z|::)/ ], - 'Response', - 'Logger', - sub { WebGUI::Middleware::Debug::Performance->wrap($_[0]) }, - ], - ); - } + my $debug = $env->{'webgui.debug'} = $self->canShowDebug($env); # Turn exceptions into HTTP errors $app = WebGUI::Middleware::HTTPExceptions->wrap($app); diff --git a/var/site.psgi b/var/site.psgi index b899357a5..83d6d97db 100644 --- a/var/site.psgi +++ b/var/site.psgi @@ -25,6 +25,20 @@ builder { config => $config, error_docs => { 500 => $config->get('maintenancePage') }; + enable_if { $_[0]->{'webgui.debug'} } 'StackTrace'; + enable_if { $_[0]->{'webgui.debug'} } 'Debug', panels => [ + 'Environment', + 'Response', + 'Timer', + 'Memory', + 'Session', + 'PerlConfig', + [ 'MySQLTrace', skip_packages => qr/\AWebGUI::SQL(?:\z|::)/ ], + 'Response', + 'Logger', + sub { WebGUI::Middleware::Debug::Performance->wrap($_[0]) }, + ]; + # This one uses the Session object, so it comes after WebGUI::Middleware::Session enable '+WebGUI::Middleware::WGAccess', config => $config;