perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <s...@stason.org>
Subject Re: [mp2] Dynamically pushing output filters -- Questions
Date Sat, 21 May 2005 03:06:56 GMT
Chris Jacobson wrote:
> Hello,
> 
>    I am attempting to write a system which allows output filters to be 
> dynamicaly pushed on the output filter stack at the end of a 
> PerlResponseHandler. 

That doesn't make any sense, Chris. By the end of the PerlResponseHandler 
the response is gone and there is nothing to filter. You can only add it 
*before* you start sending any data.

> These output filters are generated from a master 
> factory object.
> ....
> my $FilterType = "Foo";
> my $FilterObject = My::FilterFactory->new($FilterType);  # 
> Class::Factory subclassed module
> # This will generate a My::Filter::Foo object which inherits methods 
> from the factory object and overrides them as necessary
> $r->add_output_filter($FilterObject->handler); # This call will Seg 
> Fault the server

You can't call the filter, you need to pass the name of the subroutine or 
a reference to it. Please see:
http://perl.apache.org/docs/2.0/api/Apache2/Filter.html#C_add_output_filter_

The fact that you get a segfault is not good, we should take care of that. 
regardless you code is incorrect.

> I can not seem to get anything to work here except a simple coderef.  
> This defeats my entire purpose of dynamically pushing filter handlers, 
> if they can only be a simple subroutine.  Is there any possible way to 
> use an object as a filter handler, or can it only be a monolithic 
> subroutine code reference?

Filter handlers are very similar to all other mod_perl handlers, so 
whatever works for mod_perl handlers works should work for filters.
I haven't tried using objects as filter handlers. May be in a few days 
unless someone beats me to it.

-- 
__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

Mime
View raw message