home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-perl-addon-1.4.9-installer.exe / Default.pm < prev    next >
Encoding:
Perl POD Document  |  2002-11-27  |  2.6 KB  |  124 lines

  1. package CGI::Session::Serialize::Default;
  2.  
  3. # $Id: Default.pm,v 1.5 2002/11/27 12:26:08 sherzodr Exp $ 
  4. use strict;
  5. use Safe;
  6. use Data::Dumper;
  7.  
  8. use vars qw($VERSION);
  9.  
  10. ($VERSION) = '$Revision: 1.5 $' =~ m/Revision:\s*(\S+)/;
  11.  
  12.  
  13. sub freeze {
  14.     my ($self, $data) = @_;
  15.     
  16.     local $Data::Dumper::Indent   = 0;
  17.     local $Data::Dumper::Purity   = 0;
  18.     local $Data::Dumper::Useqq    = 1;
  19.     local $Data::Dumper::Deepcopy = 0;   
  20.     
  21.     my $d = new Data::Dumper([$data], ["D"]);
  22.     return $d->Dump();    
  23. }
  24.  
  25.  
  26.  
  27. sub thaw {
  28.     my ($self, $string) = @_;    
  29.  
  30.     # To make -T happy
  31.     my ($safe_string) = $string =~ m/^(.*)$/;
  32.     
  33.     my $D = undef;
  34.     my $cpt = new Safe();
  35.     $D = $cpt->reval ($safe_string );
  36.     if ( $@ ) {
  37.         die $@;
  38.     }
  39.  
  40.     return $D;
  41. }
  42.  
  43.  
  44. 1;
  45.  
  46. =pod
  47.  
  48. =head1 NAME
  49.  
  50. CGI::Session::Serialize::Default - default serializer for CGI::Session
  51.  
  52. =head1 DESCRIPTION
  53.  
  54. This library is used by CGI::Session driver to serialize session data before storing
  55. it in disk. 
  56.  
  57. =head1 METHODS
  58.  
  59. =over 4
  60.  
  61. =item freeze()
  62.  
  63. receives two arguments. First is the CGI::Session driver object, the second is the data to be
  64. stored passed as a reference to a hash. Should return true to indicate success, undef otherwise, 
  65. passing the error message with as much details as possible to $self->error()
  66.  
  67. =item thaw()
  68.  
  69. receives two arguments. First being CGI::Session driver object, the second is the string
  70. to be deserialized. Should return deserialized data structure to indicate successs. undef otherwise,
  71. passing the error message with as much details as possible to $self->error().
  72.  
  73. =back
  74.  
  75. =head1 WARNING
  76.  
  77. If you want to be able to store objects, consider using L<CGI::Session::Serialize::Storable> or
  78. L<CGI::Session::Serialize::FreezeThaw> instead.
  79.  
  80. =head1 COPYRIGHT
  81.  
  82. Copyright (C) 2002 Sherzod Ruzmetov. All rights reserved.
  83.  
  84. This library is free software. It can be distributed under the same terms as Perl itself. 
  85.  
  86. =head1 AUTHOR
  87.  
  88. Sherzod Ruzmetov <sherzodr@cpan.org>
  89.  
  90. All bug reports should be directed to Sherzod Ruzmetov <sherzodr@cpan.org>. 
  91.  
  92. =head1 SEE ALSO
  93.  
  94. =over 4
  95.  
  96. =item *
  97.  
  98. L<CGI::Session|CGI::Session> - CGI::Session manual
  99.  
  100. =item *
  101.  
  102. L<CGI::Session::Tutorial|CGI::Session::Tutorial> - extended CGI::Session manual
  103.  
  104. =item *
  105.  
  106. L<CGI::Session::CookBook|CGI::Session::CookBook> - practical solutions for real life problems
  107.  
  108. =item *
  109.  
  110. B<RFC 2965> - "HTTP State Management Mechanism" found at ftp://ftp.isi.edu/in-notes/rfc2965.txt
  111.  
  112. =item *
  113.  
  114. L<CGI|CGI> - standard CGI library
  115.  
  116. =item *
  117.  
  118. L<Apache::Session|Apache::Session> - another fine alternative to CGI::Session
  119.  
  120. =back
  121.  
  122. =cut
  123.  
  124.