=head
should notes() be available to a handler installed with
custom_response()? 

notice the code below:
        
        0) handler() decides which function will handle the response
        and sets a note.
        
        1) in test(), if part of the uri contains /error/, then
        another note is set and a custom_response() is used.
        the error() routine handles the error().  it sees the
        note set by handler() but not by test(),
        
        2) in test(), if part of the uri contains /push/, then
        a note is set and error() is installed as a handler.
        error() then sees both notes.

should 1) propogate both notes? are things even designed to work that way?
=cut

package LinkBank5::ErrorTest;

use Apache::Constants;

sub handler
        {
        my $r = shift;
        my $uri = $r->uri;
        $r->notes( 'LB-handler' => "Run at @{[scalar localtime]}" );

        if( $uri =~ /test/ )
                {
                $r->push_handlers( PerlHandler => \&test ); 
                return OK;
                }
        if( $uri =~ /error/ )
                {
                $r->push_handlers( PerlHandler => \&error ); 
                return OK;
                }
        else { return DECLINED; }
        }
        
sub test
        {
        my $r = shift;
        my $uri = $r->uri;
        
        #this note is not set, although the handler note is propogated
        if( $uri =~ /error/ ) # e.g. /test/error
                {
                $r->notes('LB-Error' => 'Oops! i messed up');
                $r->notes('error-notes' => 'Oops! i messed up');
                $r->custom_response( SERVER_ERROR, "/error" );
                
                return SERVER_ERROR; #tested with OK and DECLINED too
                }
        #using a PushHandler works
        elsif( $uri =~ /push/ ) # e.g. /test/push
                {
                $r->notes('LB-Push' => 'Oops! i messed up');
                $r->push_handlers( PerlHandler => \&error );

                return OK;
                }
                
        $r->send_http_header;
        
        my $note = $r->notes('LB-handler');
        $r->print("I'm in test!\n");
        $r->print("The note is [$note]\n");
        
        return OK;
        }
                
sub error
        {
        my $r = shift;
        
        my $notes  = $r->notes;
        my $pnotes = $r->pnotes;
        
        $r->status( SERVER_ERROR );
        $r->send_http_header;
        
        $r->print("I'm in error!\n");
        
        print "Notes are -----\n";
        print map { "$_ => $$notes{$_}\n" } sort keys %$notes;

        print "PNotes are -----\n";
        print map { "$_ => $$pnotes{$_}\n" } sort keys %$pnotes;
        
        return OK;
        }
        
1;

__END__

--
brian d foy                              <[EMAIL PROTECTED]>
Director of Technology, Smith Renaud, Inc.
875 Avenue of the Americas, 2510, New York, NY  10001
        V: (212) 239-8985

Reply via email to