[Affelio-cvs 103] CVS update: affelio/extlib/CGI/Session/Serialize

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 6月 21日 (火) 22:11:15 JST


Index: affelio/extlib/CGI/Session/Serialize/Default.pm
diff -u /dev/null affelio/extlib/CGI/Session/Serialize/Default.pm:1.1
--- /dev/null	Tue Jun 21 22:11:15 2005
+++ affelio/extlib/CGI/Session/Serialize/Default.pm	Tue Jun 21 22:11:14 2005
@@ -0,0 +1,123 @@
+package CGI::Session::Serialize::Default;
+
+# $Id: Default.pm,v 1.1 2005/06/21 13:11:14 slash5234 Exp $ 
+use strict;
+use Safe;
+use Data::Dumper;
+
+use vars qw($VERSION);
+
+($VERSION) = '$Revision: 1.1 $' =~ m/Revision:\s*(\S+)/;
+
+
+sub freeze {
+    my ($self, $data) = @_;
+    
+    local $Data::Dumper::Indent   = 0;
+    local $Data::Dumper::Purity   = 0;
+    local $Data::Dumper::Useqq    = 1;
+    local $Data::Dumper::Deepcopy = 0;   
+    
+    my $d = new Data::Dumper([$data], ["D"]);
+    return $d->Dump();    
+}
+
+
+
+sub thaw {
+    my ($self, $string) = @_;    
+
+    # To make -T happy
+    my ($safe_string) = $string =~ m/^(.*)$/;
+    
+    my $D = undef;
+    my $cpt = new Safe();
+    $D = $cpt->reval ($safe_string );
+    if ( $@ ) {
+        die $@;
+    }
+
+    return $D;
+}
+
+
+1;
+
+=pod
+
+=head1 NAME
+
+CGI::Session::Serialize::Default - default serializer for CGI::Session
+
+=head1 DESCRIPTION
+
+This library is used by CGI::Session driver to serialize session data before storing
+it in disk. 
+
+=head1 METHODS
+
+=over 4
+
+=item freeze()
+
+receives two arguments. First is the CGI::Session driver object, the second is the data to be
+stored passed as a reference to a hash. Should return true to indicate success, undef otherwise, 
+passing the error message with as much details as possible to $self->error()
+
+=item thaw()
+
+receives two arguments. First being CGI::Session driver object, the second is the string
+to be deserialized. Should return deserialized data structure to indicate successs. undef otherwise,
+passing the error message with as much details as possible to $self->error().
+
+=back
+
+=head1 WARNING
+
+If you want to be able to store objects, consider using L<CGI::Session::Serialize::Storable> or
+L<CGI::Session::Serialize::FreezeThaw> instead.
+
+=head1 COPYRIGHT
+
+Copyright (C) 2002 Sherzod Ruzmetov. All rights reserved.
+
+This library is free software. It can be distributed under the same terms as Perl itself. 
+
+=head1 AUTHOR
+
+Sherzod Ruzmetov <sherz****@cpan*****>
+
+All bug reports should be directed to Sherzod Ruzmetov <sherz****@cpan*****>. 
+
+=head1 SEE ALSO
+
+=over 4
+
+=item *
+
+L<CGI::Session|CGI::Session> - CGI::Session manual
+
+=item *
+
+L<CGI::Session::Tutorial|CGI::Session::Tutorial> - extended CGI::Session manual
+
+=item *
+
+L<CGI::Session::CookBook|CGI::Session::CookBook> - practical solutions for real life problems
+
+=item *
+
+B<RFC 2965> - "HTTP State Management Mechanism" found at ftp://ftp.isi.edu/in-notes/rfc2965.txt
+
+=item *
+
+L<CGI|CGI> - standard CGI library
+
+=item *
+
+L<Apache::Session|Apache::Session> - another fine alternative to CGI::Session
+
+=back
+
+=cut
+
Index: affelio/extlib/CGI/Session/Serialize/FreezeThaw.pm
diff -u /dev/null affelio/extlib/CGI/Session/Serialize/FreezeThaw.pm:1.1
--- /dev/null	Tue Jun 21 22:11:15 2005
+++ affelio/extlib/CGI/Session/Serialize/FreezeThaw.pm	Tue Jun 21 22:11:14 2005
@@ -0,0 +1,101 @@
+package CGI::Session::Serialize::FreezeThaw;
+
+# $Id: FreezeThaw.pm,v 1.1 2005/06/21 13:11:14 slash5234 Exp $ 
+use strict;
+use FreezeThaw;
+
+use vars qw($VERSION);
+
+($VERSION) = '$Revision: 1.1 $' =~ m/Revision:\s*(\S+)/;
+
+
+sub freeze {
+    my ($self, $data) = @_;
+    
+    return FreezeThaw::freeze($data);
+}
+
+
+
+sub thaw {
+    my ($self, $string) = @_;
+
+    return (FreezeThaw::thaw($string))[0];
+}
+
+
+1;
+
+=pod
+
+=head1 NAME
+
+CGI::Session::Serialize::FreezeThaw - serializer for CGI::Session
+
+=head1 DESCRIPTION
+
+This library is used by CGI::Session driver to serialize session data before storing
+it in disk. Uses FreezeThaw.
+
+=head1 METHODS
+
+=over 4
+
+=item freeze()
+
+receives two arguments. First is the CGI::Session driver object, the second is the data to be
+stored passed as a reference to a hash. Should return true to indicate success, undef otherwise, 
+passing the error message with as much details as possible to $self->error()
+
+=item thaw()
+
+receives two arguments. First being CGI::Session driver object, the second is the string
+to be deserialized. Should return deserialized data structure to indicate successs. undef otherwise,
+passing the error message with as much details as possible to $self->error().
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2002 Sherzod Ruzmetov. All rights reserved.
+
+This library is free software. It can be distributed under the same terms as Perl itself. 
+
+=head1 AUTHOR
+
+Sherzod Ruzmetov <sherz****@cpan*****>
+
+All bug reports should be directed to Sherzod Ruzmetov <sherz****@cpan*****>. 
+
+=head1 SEE ALSO
+
+=over 4
+
+=item *
+
+L<CGI::Session|CGI::Session> - CGI::Session manual
+
+=item *
+
+L<CGI::Session::Tutorial|CGI::Session::Tutorial> - extended CGI::Session manual
+
+=item *
+
+L<CGI::Session::CookBook|CGI::Session::CookBook> - practical solutions for real life problems
+
+=item *
+
+B<RFC 2965> - "HTTP State Management Mechanism" found at ftp://ftp.isi.edu/in-notes/rfc2965.txt
+
+=item *
+
+L<CGI|CGI> - standard CGI library
+
+=item *
+
+L<Apache::Session|Apache::Session> - another fine alternative to CGI::Session
+
+=back
+
+=cut
+
Index: affelio/extlib/CGI/Session/Serialize/Storable.pm
diff -u /dev/null affelio/extlib/CGI/Session/Serialize/Storable.pm:1.1
--- /dev/null	Tue Jun 21 22:11:15 2005
+++ affelio/extlib/CGI/Session/Serialize/Storable.pm	Tue Jun 21 22:11:14 2005
@@ -0,0 +1,101 @@
+package CGI::Session::Serialize::Storable;
+
+# $Id: Storable.pm,v 1.1 2005/06/21 13:11:14 slash5234 Exp $ 
+use strict;
+use Storable;
+use vars qw($VERSION);
+
+($VERSION) = '$Revision: 1.1 $' =~ m/Revision:\s*(\S+)/;
+
+
+sub freeze {
+    my ($self, $data) = @_;
+
+    return Storable::freeze($data);
+}
+
+
+sub thaw {
+    my ($self, $string) = @_;
+
+    return Storable::thaw($string);
+}
+
+# $Id: Storable.pm,v 1.1 2005/06/21 13:11:14 slash5234 Exp $
+
+1;
+
+=pod
+
+=head1 NAME
+
+CGI::Session::Serialize::Storable - serializer for CGI::Session
+
+=head1 DESCRIPTION
+
+This library is used by CGI::Session driver to serialize session data before storing
+it in disk. Uses Storable
+
+=head1 METHODS
+
+=over 4
+
+=item freeze()
+
+receives two arguments. First is the CGI::Session driver object, the second is the data to be
+stored passed as a reference to a hash. Should return true to indicate success, undef otherwise, 
+passing the error message with as much details as possible to $self->error()
+
+=item thaw()
+
+receives two arguments. First being CGI::Session driver object, the second is the string
+to be deserialized. Should return deserialized data structure to indicate successs. undef otherwise,
+passing the error message with as much details as possible to $self->error().
+
+=back
+
+=head1 COPYRIGHT
+
+Copyright (C) 2002 Sherzod Ruzmetov. All rights reserved.
+
+This library is free software. It can be distributed under the same terms as Perl itself. 
+
+=head1 AUTHOR
+
+Sherzod Ruzmetov <sherz****@cpan*****>
+
+All bug reports should be directed to Sherzod Ruzmetov <sherz****@cpan*****>. 
+
+=head1 SEE ALSO
+
+=over 4
+
+=item *
+
+L<CGI::Session|CGI::Session> - CGI::Session manual
+
+=item *
+
+L<CGI::Session::Tutorial|CGI::Session::Tutorial> - extended CGI::Session manual
+
+=item *
+
+L<CGI::Session::CookBook|CGI::Session::CookBook> - practical solutions for real life problems
+
+=item *
+
+B<RFC 2965> - "HTTP State Management Mechanism" found at ftp://ftp.isi.edu/in-notes/rfc2965.txt
+
+=item *
+
+L<CGI|CGI> - standard CGI library
+
+=item *
+
+L<Apache::Session|Apache::Session> - another fine alternative to CGI::Session
+
+=back
+
+=cut
+
+# $Id: Storable.pm,v 1.1 2005/06/21 13:11:14 slash5234 Exp $


Affelio-cvs メーリングリストの案内
Back to archive index