]> Dogcows Code - chaz/p5-CGI-Ex/blobdiff - lib/CGI/Ex/App.pm
CGI::Ex 2.07
[chaz/p5-CGI-Ex] / lib / CGI / Ex / App.pm
index 4a62f920b390b9228abc345090b23c1429e0415b..739c82fb755307e22a63d39f28257b1fd723639c 100644 (file)
@@ -2,7 +2,7 @@ package CGI::Ex::App;
 
 ###----------------------------------------------------------------###
 #  See the perldoc in CGI/Ex/App.pod
-#  Copyright 2006 - Paul Seamons                                     #
+#  Copyright 2007 - Paul Seamons                                     #
 #  Distributed under the Perl Artistic License without warranty      #
 ###----------------------------------------------------------------###
 
@@ -10,9 +10,10 @@ use strict;
 use vars qw($VERSION);
 
 BEGIN {
-    $VERSION = '2.05';
+    $VERSION = '2.07';
 
     Time::HiRes->import('time') if eval {require Time::HiRes};
+    eval {require Scalar::Util};
 }
 
 sub croak {
@@ -673,6 +674,29 @@ sub stash {
     return $self->{'stash'} ||= {};
 }
 
+sub clear_app {
+    my $self = shift;
+
+    delete @{ $self }{qw(
+        cgix
+        vob
+        form
+        cookies
+        stash
+        path
+        path_i
+        history
+        __morph_lineage_start_index
+        __morph_lineage
+        hash_errors
+        hash_fill
+        hash_swap
+        hash_common
+    )};
+
+    return $self;
+}
+
 ###----------------------------------------------------------------###
 ### default hook implementations
 
@@ -767,7 +791,9 @@ sub swap_template {
     my ($self, $step, $file, $swap) = @_;
 
     my $args = $self->run_hook('template_args', $step);
-    $args->{'INCLUDE_PATH'} ||= sub { $self->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"" };
+    my $copy = $self;
+    eval {require Scalar::Util; Scalar::Util::weaken($copy)};
+    $args->{'INCLUDE_PATH'} ||= sub { $copy->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"" };
 
     require CGI::Ex::Template;
     my $t = CGI::Ex::Template->new($args);
@@ -951,14 +977,8 @@ sub hash_base {
 
     return $self->{'hash_base'} ||= do {
         ### create a weak copy of self to use in closures
-        my $copy;
-        if (eval {require Scalar::Util} && defined &Scalar::Util::weaken) {
-            $copy = $self;
-            Scalar::Util::weaken($copy);
-        } else {
-            $copy = bless {%$self}, ref($self); # hackish way to avoid circular refs on older perls (pre 5.8)
-        }
-
+        my $copy = $self;
+        eval {require Scalar::Util; Scalar::Util::weaken($copy)};
         my $hash = {
             script_name     => $ENV{'SCRIPT_NAME'} || $0,
             path_info       => $ENV{'PATH_INFO'}   || '',
This page took 0.024113 seconds and 4 git commands to generate.