httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jody Biggs <j...@codegrok.com>
Subject RE: Apache::Request patch request (fwd)
Date Wed, 07 Mar 2001 18:11:59 GMT
On Wed, 7 Mar 2001, Geoffrey Young wrote:
 
> why would you want to do such a thing?  for a subrequest?  why not use
> pnotes() for that instead?

short answer: it makes my code cleaner

long answer:
well, specifically in my circumstances, I'd like to do it to remap inputs
to new names - I have a list of hidden1, hidden2, hidden3, and also get
user inputted text1, and want to set / create hidden4 to text1.  and then,
to decide which of the list of hidden1, hidden2, hidden3, and hidden4, I
check which checkboxes were checked (get the values back as an array, as
there were multiple inputs with the same name).  But I'll have potentially
1, 2, 3 checked, and I want to add 4 to that list.  To set that, I need to
set $r->param ( checkbox_name => <list of 1, 2, 3, 4> ) somehow.  Then,
later processing can treat this new set of data on the list just as if it
were originally part of the list.

The docs say it can be done (see below), but it doesn't work.

Get or set request parameters:

    my $value = $apr->param('foo');
    my @values = $apr->param('foo');
    my @params = $apr->param;
    $apr->param('foo' => [qw(one two three)]);


anyhow, it seems to me that either the documentation is incorrect, or the
code is.  The example I gave contains the code change to make the code
work as the docs say, or I suppose you could just remove that last line
above from the docs...

> I don't know that it makes sense to change the generic param() method to
> allow for holding refs when you can't get a ref from a form field.

well, see, that's the thing - first, it wouldn't really be holding a ref,
it's just accepting one to fill up it's table object with.  It would then
return an array when you access the parameter, just as will currently
happen if you submit a form that has multiple inputs with the same
name.  In fact, the reason I'm submitting this patch is because it was
returning a ref instead of an array, which indeed is something that you
can't get from a form field...  Plus, I wouldn't really call it changing
the method - I'd call it fixing it, if it's supposed to behave as the docs
say.

> there's also the parms() method that returns an Apache::Table object that
> you can use as you wish.

yeah, but I'd hate to have to resort to that if param can be changed to
work as the docs describe...

> just my $0.02

thanks for the comments, I hope I don't sound too snippy in my reply.

 - Jody




On Wed, 7 Mar 2001, Geoffrey Young wrote:

> 
> 
> > -----Original Message-----
> > From: Jody Biggs [mailto:jody@codegrok.com]
> > Sent: Tuesday, March 06, 2001 1:56 PM
> > To: apreq-dev@httpd.apache.org
> > Subject: Apache::Request patch request (fwd)
> > 
> > 
> > I was having trouble setting a param to hold multiple values, and then
> > retrieving them using Apache Request, as
> > such:
> > 
> > sub handler
> > {
> >   my $r = Apache::Request->new (shift);
> >   $r->param ( 'foo' => [qw(a few element long list)] );
> >   my @foolist = $r->param ( 'foo' );
> >   # would get scalar (@foolist) == 1
> >   # with that one element being an array ref
> >   #
> >   # actually, i'm not sure if it was an actual array ref,
> >   # or just a string containing "ARRAY(0x.......)", but whatever
> >   
> >   #...
> > }
> 
> why would you want to do such a thing?  for a subrequest?  why not use
> pnotes() for that instead?
> 
> I don't know that it makes sense to change the generic param() method to
> allow for holding refs when you can't get a ref from a form field.
> 
> there's also the parms() method that returns an Apache::Table object that
> you can use as you wish.
> 
> just my $0.02
> 
> --Geoff
> 
> [snip]
> 


Mime
View raw message