Doug MacEachern wrote:
> > At least that's what I thought !
> > 
> > In fact now Apache lets me use more then one 
> > PerlTransHandler, but it doesn't care
> > of what is the return codes are!!!
> > 
> > Even I return OK, it still calls
> > next registered handlers. Really weird!
> 
> mod_perl does care.  but, mod_perl stacked handlers are not quite the same
> as Apache C handlers.  unless the return status from a Perl handler is
> something other than OK or DECLINED, mod_perl propagates the status code
> of the last handler run back up to Apache.
> originally, stacked handlers were introduced for chaining multiple content
> handlers.  if the OK status from the first handler was propagated back to
> Apache, there would be no chain, and little use for stacked handlers.
> 
> you can always override this behavior by using a single Perl*Handler which
> decides what path to take based on the return status, or use a
> PerlDispatchHandler, or PerlDirectiveHandlers, to name a few.

I've got round this by having a module which adds a JournalsTrans directive,
which says which trans handlers to apply, then have just one PerlTransHandler,
which processes them all:

httpd.conf:
  PerlTransHandler        Journals::Frontend::handle_trans
  JournalsTrans /EJ       Journals::EJ::handle_trans
  JournalsTrans /EJ/Admin Journals::EJ::Admin::handle_trans
  JournalsTrans /Journals Journals::Info::handle_trans

sub Journals::Frontend::handle_trans{
  my($r)=@_;

  # Fetch handlers configured by Journals::Config
  if(my $cfg=Apache::ModuleConfig->get($r,'Journals::Config')){
    if(my $trans=$cfg->{JournalsTrans}){
      my $uri=$r->uri;
      foreach(@$trans){
        my($test_uri,$uri_sub,$sub)=@$_;
        if($uri_sub->($uri)){
          my $code=$sub->($r,$test_uri);
          return $code
            if $code!=DECLINED;
        }
      }
      $r->log->error("No handler matching $uri found");
    }else{
      $r->log->crit('No JournalsTrans module config found');
    }
  }else{
    $r->log->crit("Can't retrieve module config");
  }

  return DECLINED;
}


-- 
        Peter Haworth   [EMAIL PROTECTED]
If a packet hits a pocket on a socket on a port
& the bus is interrupted as a very last resort
& the memory address makes your processes abort
then the socket packet pocket has an error to report!

Reply via email to