various changes to C::P::Session, including clear_flash
Yuval Kogman [Fri, 15 Sep 2006 19:10:07 +0000 (19:10 +0000)]
Changes
lib/Catalyst/Plugin/Session.pm

diff --git a/Changes b/Changes
index 8ca9440..2eea8b5 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,10 @@
 Revision history for Perl extension Catalyst::Plugin::Session
 
-0.012
+0.13
+        - add `clear_flash`
+        - improve debug logging
+
+0.12
         - 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
index 29e4d82..887fb28 100644 (file)
@@ -99,14 +99,14 @@ sub finalize {
 sub finalize_session {
     my $c = shift;
 
+    $c->NEXT::finalize_session;
+
     $c->_save_session_id;
     $c->_save_session;
     $c->_save_flash;
     $c->_save_session_expires;
 
     $c->_clear_session_instance_data;
-
-    $c->NEXT::finalize_session;
 }
 
 sub _save_session_id {
@@ -261,7 +261,7 @@ sub _clear_session_instance_data {
 sub delete_session {
     my ( $c, $msg ) = @_;
 
-    $c->log->debug("Deleting session") if $c->debug;
+    $c->log->debug("Deleting session" . ( defined($msg) ? "($msg)" : '(no reason given)') ) if $c->debug;
 
     # delete the session data
     if ( my $sid = $c->sessionid ) {
@@ -388,6 +388,12 @@ sub flash {
     }
 }
 
+sub clear_flash {
+    my $c = shift;
+    $c->_flash_key_hashes({});
+    $c->_flash({});
+}
+
 sub session_expire_key {
     my ( $c, %keys ) = @_;
 
@@ -639,6 +645,10 @@ of every request.
         }
     }
 
+=item clear_flash
+
+Zap all the keys in the flash regardless of their current state.
+
 =item keep_flash @keys
 
 If you wawnt to keep a flash key for the next request too, even if it hasn't