[Catalyst-commits] r7106 - in trunk/Catalyst-Engine-Wx/lib/Catalyst: . Plugin Plugin/Session Plugin/Session/State

eriam at dev.catalyst.perl.org eriam at dev.catalyst.perl.org
Fri Nov 9 13:43:31 GMT 2007


Author: eriam
Date: 2007-11-09 13:43:31 +0000 (Fri, 09 Nov 2007)
New Revision: 7106

Added:
   trunk/Catalyst-Engine-Wx/lib/Catalyst/Plugin/
   trunk/Catalyst-Engine-Wx/lib/Catalyst/Plugin/Session/
   trunk/Catalyst-Engine-Wx/lib/Catalyst/Plugin/Session/State/
   trunk/Catalyst-Engine-Wx/lib/Catalyst/Plugin/Session/State/Wx.pm
Log:
Session state very simple

Added: trunk/Catalyst-Engine-Wx/lib/Catalyst/Plugin/Session/State/Wx.pm
===================================================================
--- trunk/Catalyst-Engine-Wx/lib/Catalyst/Plugin/Session/State/Wx.pm	                        (rev 0)
+++ trunk/Catalyst-Engine-Wx/lib/Catalyst/Plugin/Session/State/Wx.pm	2007-11-09 13:43:31 UTC (rev 7106)
@@ -0,0 +1,105 @@
+package Catalyst::Plugin::Session::State::Wx;
+use base qw/Catalyst::Plugin::Session::State Class::Accessor::Fast/;
+
+use strict;
+use warnings;
+
+use NEXT;
+
+our $VERSION = "0.01_01";
+
+BEGIN { __PACKAGE__->mk_accessors(qw/_deleted_session_id/) }
+
+our $SESSIONS = ();
+
+sub setup_session {
+    my $c = shift;
+
+    $c->NEXT::setup_session(@_);
+}
+
+sub set_session_id {
+    my ( $c, $sid ) = @_;
+
+    $SESSIONS->{'sid'} = $sid;
+
+    return $c->NEXT::set_session_id($sid);
+}
+
+sub get_session_id {
+    my $c = shift;
+
+    if ( !$c->_deleted_session_id and $SESSIONS->{'sid'} ) { 
+        my $sid = $SESSIONS->{'sid'};
+        $c->log->debug(qq/Found sessionid "$sid" in cookie/) if $c->debug;
+        return $sid if $sid;
+    }
+
+    $c->NEXT::get_session_id(@_);
+}
+
+sub delete_session_id {
+    my ( $c, $sid ) = @_;
+    
+    $c->_deleted_session_id(1); # to prevent get_session_id from returning it
+
+    delete $SESSIONS->{'sid'};
+
+    $c->NEXT::delete_session_id($sid);
+}
+
+__PACKAGE__
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Catalyst::Plugin::Session::State::Wx - Maintain session using in process memory for the Wx engine.
+
+=head1 SYNOPSIS
+
+    use Catalyst qw/Session Session::State::Wx Session::Store::Foo/;
+
+=head1 DESCRIPTION
+
+Generally, L<Catalyst::Plugin::Session> requires that the session ID is 
+stored on the client but since with the Wx engine the engine and the client
+is in the same memory space we just need to store the session sid locally.
+
+=head1 EXTENDED METHODS
+
+=over 4
+
+=item setup_session
+
+It just does nothing special.
+
+=back
+
+=head1 SEE ALSO
+
+L<Catalyst>, L<Catalyst::Plugin::Session>.
+
+=head1 AUTHORS
+
+This module is derived from L<Catalyst::Plugin::Session::State::Cookie> code, and
+has been heavily modified since.
+
+Andrew Ford
+Andy Grundman
+Christian Hansen
+Yuval Kogman, C<nothingmuch at woobling.org>
+Marcus Ramberg
+Sebastian Riedel
+and Eriam Schaffter for putting this together for the Wx engine.
+
+=head1 COPYRIGHT
+
+This program is free software, you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;




More information about the Catalyst-commits mailing list