jimw        00/12/22 18:40:52

  Modified:    .        Changes
               Request  Request.pm
  Log:
  singleton support
  
  Revision  Changes    Path
  1.24      +4 -0      httpd-apreq/Changes
  
  Index: Changes
  ===================================================================
  RCS file: /home/cvs/httpd-apreq/Changes,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- Changes   2000/12/19 01:19:41     1.23
  +++ Changes   2000/12/23 02:40:52     1.24
  @@ -2,6 +2,10 @@
   
   =over 4
   
  +=item 0.31_03 - December 23, 2000
  +
  +Apache::Request->instance [Matt Sergeant <[EMAIL PROTECTED]>]
  +
   =item 0.31_02 - December 17, 2000
   
   autoconf support
  
  
  
  1.10      +38 -1     httpd-apreq/Request/Request.pm
  
  Index: Request.pm
  ===================================================================
  RCS file: /home/cvs/httpd-apreq/Request/Request.pm,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Request.pm        2000/12/19 01:19:41     1.9
  +++ Request.pm        2000/12/23 02:40:52     1.10
  @@ -6,7 +6,7 @@
   
   {
       no strict;
  -    $VERSION = '0.3102';
  +    $VERSION = '0.3103';
       @ISA = qw(Apache);
       __PACKAGE__->mod_perl::boot($VERSION);
   }
  @@ -26,6 +26,17 @@
       return wantarray ? ($tab->get($name)) : scalar $tab->get($name);
   }
   
  +sub instance {
  +    my $class = shift;
  +    my $r = shift;
  +    if (my $apreq = $r->pnotes('apreq')) {
  +        return $apreq;
  +    }
  +    my $new_req = $class->new($r, @_);
  +    $r->pnotes('apreq', $new_req);
  +    return $new_req;
  +}
  +
   1;
   __END__
   
  @@ -90,6 +101,32 @@
    }
   
   =back
  +
  +=item instance
  +
  +The instance() class method allows Apache::Request to be a singleton.
  +This means that whenever you call Apache::Request->instance() within a
  +single request you always get the same Apache::Request object back.
  +This solves the problem with creating the Apache::Request object twice
  +within the same request - the symptoms being that the second
  +Apache::Request object will not contain the form parameters because
  +they have already been read and parsed.
  +
  +  my $apr = Apache::Request->instance($r, DISABLE_UPLOADS => 1);
  +
  +Note that C<instance()> call will take the same parameters as the above
  +call to C<new()>, however the parameters will only have an effect the
  +first time C<instance()> is called within a single request. Extra
  +parameters will be ignored on subsequent calls to C<instance()> within
  +the same request.
  +
  +Subrequests receive a new Apache::Request object when they call
  +instance() - the parent request's Apache::Request object is not copied
  +into the subrequest.
  +
  +Also note that it is unwise to use the C<parse()> method when using
  +C<instance()> because you may end up trying to call it twice, and
  +detecting errors where there are none.
   
   =item parse
   
  
  
  

Reply via email to