[Catalyst] Change in $c->engine->prepare_parameters

Bill Moseley moseley at hank.org
Fri Aug 3 13:39:34 GMT 2012

I have some older code that calls $c->prepare_parameters after making some
modification to the request.   If that's an acceptable use is questionable,
but we have a change in behavior regardless from 5.90007 to 5.90008-TRIAL.

Essentially, now if you do some thing a bit odd like this:

$c->req->parameters( {} );

Then $c->req->parameters stays an empty hash.  Previous to 5.90008-TRIAL
this would prepare the parameters again.

The documentation in C::Engine says:

> =3Dhead2 $self->prepare_parameters($c)

> sets up parameters from query and post parameters.

which is only true now when $req->parameters has not already been called.

And in 5.90008-TRIAL the prepare_parameters was moved to Catalyst::Request,
with the documentation:

=3Dhead2 $self->prepare_parameters()

Ensures that the body has been parsed, then builds the parameters, which are
> combined from those in the request and those in the body.

What it doesn't do any more is set $c->req->parameters when called
directly, only when called as a builder.

I don't think prepare_parameters should be both a builder AND a method.
What about this approach:

Change the Request parameters attribute to have a builder and a clearer:

has parameters =3D> (
    is =3D> 'rw',
    lazy =3D> 1,
    builder =3D> '_build_parameters',
    clearer =3D> 'clear_parameters',

Then rename the existing "prepare_parameters" to "_build_parameters",
because that's what it is, and then add a new method:

sub prepare_parameters {
    my $self =3D shift;
    return $self->parameters;

And likewise in the Engine.pm:

sub prepare_parameters {
    my ( $self, $c ) =3D @_;
    return $c->request->parameters;

-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20120803/8d0cf=

More information about the Catalyst mailing list