I need some help with understanding the Class::MOP::Method docs.  Can I use
that to apply a modifier?


Catalyst used to call $c->prepare_body_chunk which made it easy for a
plugin or role to track upload progress.   Now, this all happens in a loop
in the Catalyst::Request instance in its prepare_body() method.

        while ( defined ( my $buffer = $self->read() ) ) {
            $self->prepare_body_chunk($buffer);
        }

For upload progress I need to know the query params, have access to the
cache (to save the progress), and the bytes read so far, of course.   But,
I'm not sure how best to get at that.

I can get at the request object before this code is run
($c->req->meta->get_method). Is is possible to use
Class::MOP::Method::Wrapped to wrap, say, read with a closure that has the
cache object and some unique upload ID?

Essentially what I want is something like this, unless, of course, there's
an easier way I've missed:

my $cache = $c->cache;
my $token = $c->req->parameters->{token};

# somehow apply this to "after" $c->request->meta->get_method( 'read' )
sub { $cache->increment( $token, shift->_read_position ) };


Is it possible to add a modifier like that?

Thanks,


-- 
Bill Moseley
mose...@hank.org

Reply via email to