You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Adam Prime <ds...@gmail.com> on 2005/07/10 22:50:05 UTC
APR::Request::Param::Table
are the add and set functions implemented in this module? I'm getting
errors like this:
Can't locate object method "set" via package "APR::Request::Param::Table"
Can't locate object method "add" via package "APR::Request::Param::Table"
I was trying to get $r->param('blah' => whatever) to work, then I
noticed that perldoc Apache2::Request says this:
* You must use the "Apache::Request::Table" API via "scalar
$req->args" or "scalar $req->body" to assign new parameters
to the request. You may no longer use the two-argument method
calls; e.g.
$req->param("foo" => "bar"); # NO: usage error in 2.X
$req->args->{foo} = "bar"; # OK: assign to args table
$req->body->add(foo => "bar"); # OK: add to body table
$req->param->add(foo => "bar"); # NO: this is an
expensive noop,
# because the
param table is
# generated by
overlaying $req->args
# and $req->body.
my $params = $req->param;
$params->set(foo => "bar"); # OK: sets "foo"
entry in $params, which
# is a local (args +
body) table. Neither
# $req->args,
$req->body, nor future calls
# to $req->param, are
affected by mods to
# $params.
Maybe i'm reading this wrong, but i'd think that the lines commented
with OK will work, but I can't get any them to.
Adam
Re: APR::Request::Param::Table
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Adam Prime <ds...@gmail.com> writes:
> is it just $req->param that is a const, or are both args and body
> const as well?
All tables, even including $req->jar.
> Is there an easy (ie one line) way to rip the entire contents of
> $req->param into a hash I can actually modify the contents of,
This should work (I think), assuming your params are single-valued:
my %param = %{$req->param};
--
Joe Schaefer
Re: APR::Request::Param::Table
Posted by Adam Prime <ds...@gmail.com>.
is it just $req->param that is a const, or are both args and body const as well?
Is there an easy (ie one line) way to rip the entire contents of
$req->param into a hash I can actually modify the contents of, or do i
need to do that myself? Personally, i did stuff like that quite a bit
in mp1.
Adam
On 7/11/05, Joe Schaefer <jo...@sunstarsys.com> wrote:
> "Philip M. Gollucci" <pg...@p6m7g8.com> writes:
>
> > You're saying I can't do:
> > sub handler {
> >
> > my $r = shift;
> > my $req = Apache2::Request->new($r);
> > my $FORM = $req->param;
> > $FORM->{foo} = 'bar'; ### line 20
>
> Right- that's no longer allowed.
>
> > Is this because of the underlying APR implementation,
> > or has the tied hash STORE function just not been
> > implemented yet?
>
> The underlying C implementation is a const apr_table_t *
> (see apreq_module.h). So technically we shouldn't implement
> a STORE method on that.
>
> --
> Joe Schaefer
>
>
Re: APR::Request::Param::Table
Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Philip M. Gollucci" <pg...@p6m7g8.com> writes:
> You're saying I can't do:
> sub handler {
>
> my $r = shift;
> my $req = Apache2::Request->new($r);
> my $FORM = $req->param;
> $FORM->{foo} = 'bar'; ### line 20
Right- that's no longer allowed.
> Is this because of the underlying APR implementation,
> or has the tied hash STORE function just not been
> implemented yet?
The underlying C implementation is a const apr_table_t *
(see apreq_module.h). So technically we shouldn't implement
a STORE method on that.
--
Joe Schaefer
Re: APR::Request::Param::Table
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Joe Schaefer wrote:
> You can't do it anymore with apreq's 2.x API.
> This functionality was dropped with 2.05-dev,
> but the docs weren't updated properly to reflect
> the change. Sorry about that.
You're saying I can't do:
sub handler {
my $r = shift;
my $req = Apache2::Request->new($r);
my $FORM = $req->param;
$FORM->{foo} = 'bar'; ### line 20
$r->content_type('text/plain');
print STDERR Dumper $FORM;
return Apache2::Const::OK;
}
[Sun Jul 10 21:04:48 2005] [error] [client 127.0.0.1] Can't locate
object method "STORE" via package "APR::Request::Param::Table" at
/usr/local/apps/httpd-2.0.54/packages/TEST/args.pm line 20.
Is this because of the underlying APR implementation, or has the tied
hash STORE function just not been implemented yet?
--
END
------------------------------------------------------------
What doesn't kill us can only make us stronger.
Nothing is impossible.
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
http://www.liquidityservicesinc.com
http://www.liquidation.com
http://www.uksurplus.com
http://www.govliquidation.com
http://www.gowholesale.com
Re: APR::Request::Param::Table
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Adam Prime <ds...@gmail.com> writes:
> Here's how i would have done what i'm trying to do in mp1. The docs
> say this interface is broken, but they aren't explaining to me very
> clearly what i'm supposed to do to get this sort of functionality in
> mp2
You can't do it anymore with apreq's 2.x API.
This functionality was dropped with 2.05-dev,
but the docs weren't updated properly to reflect
the change. Sorry about that.
--
Joe Schaefer
Re: APR::Request::Param::Table
Posted by Adam Prime <ds...@gmail.com>.
On 7/10/05, Philip M. Gollucci <pg...@p6m7g8.com> wrote:
> No, APR::Request::Param::Table does not implement get/set.
>
> You have to use the Apache2::Request interface.
>
> If you look at it's new() method, it basically gives you an
> APR::Apache2::Request object back. But I can't for the life of me find
> where its finally implemented here, but it is, because the
> Apache2::Request interface works.
Here's how i would have done what i'm trying to do in mp1. The docs
say this interface is broken, but they aren't explaining to me very
clearly what i'm supposed to do to get this sort of functionality in
mp2
sub handler {
my $r = Apache::Request->instance(shift);
$r->param('foo' => 'bar');
$r->content_type('text/plain');
print $r->param('foo') ."\n";
return OK;
}
The docs pointed me trying these:
$req->args->{foo} = "bar"; # OK: assign to args table
$req->body->add(foo => "bar"); # OK: add to body table
the errors i get from those, respective are:
[Sun Jul 10 20:14:55 2005] [error] [client 127.0.0.1] Can't locate
object method "STORE" via package "APR::Request::Param::Table" at
/www/perl/Crap/Test.pm line 12.\n
[Sun Jul 10 20:14:00 2005] [error] [client 127.0.0.1] Can't locate
object method "add" via package "APR::Request::Param::Table" at
/www/perl/Crap/Test.pm line 11.\n
I realize i'm probably just repeating myself here, but something
doesn't seem right. The docs say this:
* You must use the "Apache::Request::Table" API via "scalar
$req->args" or "scalar $req->body" to assign new parameters to the
request.
But what i get out of scalar $req->args isn't an
Apache::Request::Table object, it's an APR::Request::Param::Table
object.
So yeah, i'm confused.
Adam
Re: APR::Request::Param::Table
Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Adam Prime wrote:
> are the add and set functions implemented in this module? I'm getting
> errors like this:
>
> Can't locate object method "set" via package "APR::Request::Param::Table"
> Can't locate object method "add" via package "APR::Request::Param::Table"
No, APR::Request::Param::Table does not implement get/set.
You have to use the Apache2::Request interface.
If you look at it's new() method, it basically gives you an
APR::Apache2::Request object back. But I can't for the life of me find
where its finally implemented here, but it is, because the
Apache2::Request interface works.
--
END
------------------------------------------------------------
What doesn't kill us can only make us stronger.
Nothing is impossible.
Philip M. Gollucci (pgollucci@p6m7g8.com) 301.254.5198
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Developer / Liquidity Services, Inc.
http://www.liquidityservicesinc.com
http://www.liquidation.com
http://www.uksurplus.com
http://www.govliquidation.com
http://www.gowholesale.com