releng for C::P::Session 0.012 - minor refactorings for Store::Delegate v0.12
Yuval Kogman [Sat, 26 Aug 2006 17:44:03 +0000 (17:44 +0000)]
Changes
lib/Catalyst/Plugin/Session.pm
lib/Catalyst/Plugin/Session/Test/Store.pm
t/99_prereq.t [deleted file]

diff --git a/Changes b/Changes
index 42ea9f0..8ca9440 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
 Revision history for Perl extension Catalyst::Plugin::Session
 
+0.012
+        - refactor out a hookable finalize_session method, for plugins
+        - make _clear_session_instance_data call NEXT::, so that plugins can
+          hook on to that too
+
 0.11
         - Lazify expiry calculation and store it in a different instance data
           slot. This provides greater flexibility for implementing hooks like
index 3ad186c..29e4d82 100644 (file)
@@ -12,7 +12,7 @@ use Digest              ();
 use overload            ();
 use Object::Signature   ();
 
-our $VERSION = "0.11";
+our $VERSION = "0.12";
 
 my @session_data_accessors; # used in delete_session
 BEGIN {
@@ -91,6 +91,14 @@ sub prepare_action {
 sub finalize {
     my $c = shift;
 
+    $c->finalize_session;
+    
+    $c->NEXT::finalize(@_);
+}
+
+sub finalize_session {
+    my $c = shift;
+
     $c->_save_session_id;
     $c->_save_session;
     $c->_save_flash;
@@ -98,7 +106,7 @@ sub finalize {
 
     $c->_clear_session_instance_data;
 
-    $c->NEXT::finalize(@_);
+    $c->NEXT::finalize_session;
 }
 
 sub _save_session_id {
@@ -247,6 +255,7 @@ sub _expire_session_keys {
 sub _clear_session_instance_data {
     my $c = shift;
     $c->$_(undef) for @session_data_accessors;
+    $c->NEXT::_clear_session_instance_data; # allow other plugins to hook in on this
 }
 
 sub delete_session {
@@ -786,6 +795,12 @@ Or even more directly, replace C<generate_session_id>:
 Also have a look at L<Crypt::Random> and the various openssl bindings - these
 modules provide APIs for cryptographically secure random data.
 
+=item finalize_session
+
+Clean up the session during C<finalize>.
+
+This clears the various accessors after saving to the store.
+
 =item dump_these
 
 See L<Catalyst/dump_these> - ammends the session data structure to the list of
index 6f0db9b..830df41 100644 (file)
@@ -7,7 +7,7 @@ use warnings;
 
 use utf8;
 
-use Test::More tests => 19;
+use Test::More;
 use File::Temp;
 use File::Spec;
 
@@ -17,6 +17,8 @@ sub import {
     shift;
     my %args = @_;
 
+    plan tests => 19 + ($args{extra_tests} || 0);
+
     my $backend = $args{backend};
     my $cfg     = $args{config};
 
diff --git a/t/99_prereq.t b/t/99_prereq.t
deleted file mode 100644 (file)
index bcfb392..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use warnings;
-
-use Test::Prereq::Build;
-prereq_ok();
-