Re: [mp2] disabling a perl handler within a specific location

2003-03-04 Thread Thomas Klausner
Hi!

On Tue, Mar 04, 2003 at 12:54:30AM -0500, Matt Avitable wrote:

 Does anyone know how one goes about disabling a particular handler 
 within a specific location?  For example, consider the following:
 
Location /
 PerlInitHandler config
 PerlOutputFilterHandler filter
 /Location
 
LocationMatch /(images|gfx)/
   ## what can I put here to say don't run to the above handlers?
/Location

This works for Auth*Handlers, so it should work for any phase:

LocationMatch /(images|gfx)/
   PerlInitHandler Apache::Constants::OK
/Location

See recipy 7.3 in the Cookbook


-- 
#!/usr/bin/perl   http://domm.zsi.at
for(ref bless{},just'another'perl'hacker){s-:+-$-gprint$_.$/}


Re: [mp2] disabling a perl handler within a specific location

2003-03-03 Thread Stas Bekman
Matt Avitable wrote:
Hi list :-)

Does anyone know how one goes about disabling a particular handler 
within a specific location?  For example, consider the following:

   Location /
PerlInitHandler config
PerlOutputFilterHandler filter
/Location
   LocationMatch /(images|gfx)/
## what can I put here to say don't run to the above handlers?
   /Location
## OR

Files ~ \.(jpg|jpe?g|gif|png)$
## something here...
/Files
For all HTTP requests for files everywhere excluding directories with 
/images/ and /gfx/ in it, I want to
run my PerlInitHandler and my PerlOutputFilterHandler.  All my handlers 
do is set up some config variables
and run an xml filter.  It's useless overhead to run these handlers on 
images.
This is not really a mp2 specific question I believe, unless I'm missing 
something. You have to do the same in mp1.

I guess there might be a way to do that, but the simplest idiomatic modperl 
approach is to make the decisions once you are inside the Init handler.

  Location /
 PerlInitHandler Foo::handler
  /Location
package Foo;
# load the modules/constants here
sub handler {
  my $r = shift;
  return Apache::DECLINED if $r-uri =~ /(?:jpe?g|gif|png)$/;
  $r-push_handlers(PerlOutputFilterHandler = \filter_handler);
  return Apache::OK;
}
1;
p.s. I've optimized your /jpg|jpe?g/ regex ;)

Also you may need this :)
http://perl.apache.org/docs/2.0/api/ModPerl/MethodLookup.html
__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com