Re: [mp2] Dynamically pushing output filters -- Questions

[prev] [thread] [next] [Date index for 2005/05/22]

From: Chris Jacobson
Subject: Re: [mp2] Dynamically pushing output filters -- Questions
Date: 14:25 on 22 May 2005
Tom Schindl wrote:

> Chris Jacobson schrieb:
> | 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.  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
> | .....
> |
>
> This is once more you benefit form the perl-closures many people stumble
> about ;-)
>
> $r->add_output_filter(sub { $FilterObject->handler(@_) });
>
> Tom
>
Brilliant.  That works out perfectly!  Adding the filter this way plus 
making some minor changes to my factory generated filter objects has 
solved the problem (and the seg faults!).  Thanks Tom and Stas for the 
pointers.

        -- 
        Chris Jacobson
Online-Rewards.com
2900 Jefferson Ave.
Cincinnati, OH 45219

(513) 665-9070 x310
http://www.online-rewards.com

Re: [mp2] Dynamically pushing output filters -- Questions
Chris Jacobson 14:25 on 22 May 2005

Generated at 15:53 on 25 May 2005 by mariachi v0.52