[Jifty-commit] r2599 - Jifty-DBI/branches/od/lib/Jifty/DBI

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Fri Jan 26 08:52:57 EST 2007


Author: audreyt
Date: Fri Jan 26 08:52:53 2007
New Revision: 2599

Modified:
   Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm

Log:
* Another try at warning avoidance.

Modified: Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm
==============================================================================
--- Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm	(original)
+++ Jifty-DBI/branches/od/lib/Jifty/DBI/Schema.pm	Fri Jan 26 08:52:53 2007
@@ -74,17 +74,20 @@
 # TODO - This "sub import" is strictly here to catch the deprecated "length is 40".
 #        Once the deprecation cycle is over we should take this away and rever to
 #        "use Exporter::Lite" in the line above.
-sub import {
-    my $old_sig_die = $SIG{__DIE__};
+my $old_sig_die;
 
-    $SIG{__DIE__} = sub {
-        # Calling it by hand means we restore the old sighandler.
-        no warnings qw( uninitialized numeric );
-        $SIG{__DIE__} = (($old_sig_die == $SIG{__DIE__}) ? undef : $old_sig_die);
-        return unless @_;
+sub import {
+    no warnings qw( uninitialized numeric );
+    $old_sig_die ||= $SIG{__DIE__};
+    $SIG{__DIE__} = \&filter_die unless $SIG{__DIE__} and $SIG{__DIE__} == \&filter_die;
+    goto &Exporter::Lite::import;
+}
 
-        if ($_[0] =~ /near "is (\d+)"/) {
-            carp @_, << ".";
+sub filter_die {
+    # Calling it by hand means we restore the old sighandler.
+    $SIG{__DIE__} = $old_sig_die;
+    if ($_[0] =~ /near "is (\d+)"/) {
+        carp @_, << ".";
 
 *********************************************************
 
@@ -105,15 +108,15 @@
 
 
 .
-            exit 1;
-        }
-        elsif ($_[0] =~ /Undefined subroutine &Jifty::DBI::Schema::column|Can't locate object method "type" via package "(?:is|are)"/) {
-            my $from = (caller)[0];
-            $from =~ s/::Schema$//;
-            my $base = $INC{'Jifty/Record.pm'} ? "Jifty::Record" : "Jifty::DBI::Record";
+        exit 1;
+    }
+    elsif ($_[0] =~ /Undefined subroutine &Jifty::DBI::Schema::column|Can't locate object method "type" via package "(?:is|are)"/) {
+        my $from = (caller)[0];
+        $from =~ s/::Schema$//;
+        my $base = $INC{'Jifty/Record.pm'} ? "Jifty::Record" : "Jifty::DBI::Record";
 
-            no strict 'refs';
-            carp @_, << ".";
+        no strict 'refs';
+        carp @_, << ".";
 *********************************************************
 
  Calling 'column' within a schema class is an error:
@@ -133,14 +136,12 @@
 
 *********************************************************
 .
-        }
-
-        die @_;
-    };
+    }
 
-    goto &Exporter::Lite::import;
+    die @_;
 }
 
+
 sub by { @_ }
 
 =head1 FUNCTIONS


More information about the Jifty-commit mailing list