From: Mark K. <seg...@us...> - 2002-09-26 17:48:39
|
Update of /cvsroot/formmagick/formmagick/lib/CGI In directory usw-pr-cvs1:/tmp/cvs-serv9196/lib/CGI Modified Files: Tag: MITEL-0_87 Persistent.pm Log Message: The patched CGI::Persistent required for the previous fixes Index: Persistent.pm =================================================================== RCS file: /cvsroot/formmagick/formmagick/lib/CGI/Persistent.pm,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -r1.2.2.1 -r1.2.2.2 *** Persistent.pm 26 Sep 2002 17:46:24 -0000 1.2.2.1 --- Persistent.pm 26 Sep 2002 17:48:34 -0000 1.2.2.2 *************** *** 11,18 **** package CGI::Persistent; ! use CGI; use Persistence::Object::Simple; use vars qw(@ISA $VERSION); use Data::Dumper; @ISA = qw( CGI ); ( $VERSION ) = '$Revision$' =~ /(\d+\.\d+)/; --- 11,19 ---- package CGI::Persistent; ! use CGI '-no_xhtml'; use Persistence::Object::Simple; use vars qw(@ISA $VERSION); use Data::Dumper; + use File::Basename; @ISA = qw( CGI ); ( $VERSION ) = '$Revision$' =~ /(\d+\.\d+)/; *************** *** 22,35 **** $dope = "." unless $dope; my $cgi = new CGI; # print $cgi->header (); ! my $fn = $cgi->param( '.id' ) || $id; unless ( $fn ) { my $po = new Persistence::Object::Simple ( __Dope => $dope ); ! $cgi->append( -name => '.id', -values => $po->{ __Fn } ); ! $fn = $po->{ __Fn }; undef $po; } ! my $po = new Persistence::Object::Simple __Fn => $fn; $po->{ __DOPE } = undef; my @names = $cgi->param (); --- 23,38 ---- $dope = "." unless $dope; my $cgi = new CGI; # print $cgi->header (); ! my $fn = basename($cgi->param( '.id' ) || $id); unless ( $fn ) { my $po = new Persistence::Object::Simple ( __Dope => $dope ); ! $cgi->append( -name => '.id', -values => basename $po->{ __Fn } ); ! $fn = basename $po->{ __Fn }; undef $po; } ! my $po = new Persistence::Object::Simple __Fn => ! join "/", ($dope,$fn); $po->{ __DOPE } = undef; + $po->{sessiondir} = $dope; my @names = $cgi->param (); *************** *** 41,47 **** foreach $key ( keys %$po ) { $cgi->param( -name => $key, -values => $po->{$key} ) ! unless ( grep /$key/, @names ) || $key eq "__Fn" } $po->commit (); return bless $cgi, $class; --- 44,52 ---- foreach $key ( keys %$po ) { $cgi->param( -name => $key, -values => $po->{$key} ) ! unless ( grep /$key/, @names ) || $key eq "__Fn"; } + $cgi->{sessiondir} = $po->{sessiondir}; + $po->commit (); return bless $cgi, $class; *************** *** 113,132 **** print $cgi->header (); my $url = $cgi->state_url (); ! print "<a href=$u>I am a persistent CGI session.</a>"; =head1 SOLUTION TO THE STATELESS PROBLEM ! HTTP is a stateless protocol; a HTTP server closes connection after serving ! an object. It retains no memory of the request details and doesn't relate ! subsequent requests with what it has already served. While this works well ! for static resources like HTML pages and image elements, complex user ! interactions often require state preservation across multiple requests and ! different parts of the web resource. Statefulness on a stateless server ! is achieved either through client-side mechanisms like Netscape cookies ! (which are considered distasteful on general principles of privacy) or with ! hidden fields in forms and value-attribute pairs in the URLs. State ! preserving URLs are more desirable, because they are independent of the ! client configuration, but tend to get unwieldy with increase in space ! complexity of the application. CGI::Persistent solves this problem by introducing persistent CGI sessions --- 118,136 ---- print $cgi->header (); my $url = $cgi->state_url (); ! print "<a href=$url>I am a persistent CGI session.</a>"; =head1 SOLUTION TO THE STATELESS PROBLEM ! HTTP is a stateless protocol; a HTTP server closes connection after ! serving an object. It retains no memory of the request details and doesn't ! relate subsequent requests with what it has already served. While this ! works well for static resources like HTML pages and image elements, ! complex user interactions often require state preservation across multiple ! requests and different parts of the web resource. Statefulness on a ! stateless server is achieved either through client-side mechanisms like ! Netscape cookies or with hidden fields in forms and value-attribute pairs ! in the URLs. State preserving URLs are more desirable, because they are ! independent of the client configuration, but tend to get unwieldy with ! increase in space complexity of the application. CGI::Persistent solves this problem by introducing persistent CGI sessions *************** *** 147,156 **** =item B<new()> ! Creates a new CGI object and binds it to its associated persistent state. A ! new state image is created if no associated state exists. new() takes two ! optional arguments. The first argument is the directory of persistence, the ! place where state information is stored. Ideally, this should be a separate ! directory dedicated to state files. When a directory is not specified, the ! current working directory is assumed. new() can also take a state id on the argument list instead of getting it --- 151,160 ---- =item B<new()> ! Creates a new CGI object and binds it to its associated persistent state. ! A new state image is created if no associated state exists. new() takes ! two optional arguments. The first argument is the directory of ! persistence, the place where state information is stored. Ideally, this ! should be a separate directory dedicated to state files. When a directory ! is not specified, the current working directory is assumed. new() can also take a state id on the argument list instead of getting it *************** *** 161,166 **** $q = new CGI::Persistent; ! $q = new CGI::Persistent "/dope"; ! $q = new CGI::Persistent undef, "/dope/924910985.134"; =item B<state_url()> --- 165,170 ---- $q = new CGI::Persistent; ! $q = new CGI::Persistent "/sessions"; ! $q = new CGI::Persistent undef, "/sessions/924910985.134"; =item B<state_url()> |