[Bps-public-commit] Prophet branch, master, updated. f9bdf3011982c370ac7642fcdc5c90bcdedac518

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 12 14:06:45 EDT 2009


The branch, master has been updated
       via  f9bdf3011982c370ac7642fcdc5c90bcdedac518 (commit)
      from  fa5eaa4a64739638fb8aa61f0867434f7ca004c4 (commit)

Summary of changes:
 lib/Prophet/Server/View.pm |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

- Log -----------------------------------------------------------------
commit f9bdf3011982c370ac7642fcdc5c90bcdedac518
Author: Shawn M Moore <sartak at gmail.com>
Date:   Wed Aug 12 14:06:24 2009 -0400

    Silence redefinition warning caused by Exporter::Lite and $^W

diff --git a/lib/Prophet/Server/View.pm b/lib/Prophet/Server/View.pm
index 6d761c6..aa6104b 100644
--- a/lib/Prophet/Server/View.pm
+++ b/lib/Prophet/Server/View.pm
@@ -5,9 +5,24 @@ package Prophet::Server::View;
 use base 'Template::Declare';
 
 use Template::Declare::Tags;
+
+# Prophet::Server::ViewHelpers overwrites the form {} function provided by
+# Template::Declare::Tags. ViewHelpers uses Exporter::Lite which does not "use
+# warnings". When prove -w or make test is run, $^W is set which turns on
+# warnings in Exporter::Lite (most importantly, redefinition warnings). We
+# don't want to warn about this specific redefinition, so we swap out
+# $SIG{__WARN__} to shut up about it.
+
 BEGIN {
-    no warnings 'redefine'; # we stomp on form{}
-    use Prophet::Server::ViewHelpers;
+    no warnings 'redefine';
+    my $old_warn = $SIG{__WARN__} || sub { warn $_[0] };
+    local $SIG{__WARN__} = sub {
+        my $warning = shift;
+        $old_warn->($warning)
+            unless $warning =~ /Subroutine Prophet::Server::View::form redefined /;
+    };
+    require Prophet::Server::ViewHelpers;
+    Prophet::Server::ViewHelpers->import;
 }
 use Params::Validate;
 use Prophet::Web::Menu;

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list