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 Patrick Galbraith <pa...@mysql.com> on 2006/10/28 01:30:00 UTC

$reg->param, $req->body - is there a way to set form data?

Hi all,

I have in my code what used to work on 1.0. I have this variable, $form, 
which is a reference for $req->param. I had cases in the code where 
something is submitted in a form that is incorrect, and I want to change 
the op of the form by setting $form->{op} (the code has a hash reference 
to different subroutines that are keyed by op's value). Now when I do 
this, I get this error:

Can't locate object method "STORE" via package 
"APR::Request::Param::Table" at 
/var/www/perl-lib/WebLib/Application/UserReg.pm line 360.\n, referer: 
http://www.patg.net/userreg

Reading the docs, it looks like you can't _set_ a value this way any 
more. Or can you? Is there a way? It's pretty important that I can do 
this. Otherwise, more re-writing.

Thanks in advance for info on this.

--Patrick


Re: $reg->param, $req->body - is there a way to set form data?

Posted by Jonathan Vanasco <ap...@2xlp.com>.
On Oct 27, 2006, at 8:25 PM, Philip M. Gollucci wrote:

> You can not, they are readonly versions of APR::Table (apr_table_t)
>
> You could always copy the structure to a hash somewhere.  Also,  
> check the archvies of this
> list, I know someone (probably joes) posted an answer to this  
> question before.

Just to add-

I think that approach can lead to some big problems.

I'd strongly suggest having a Form class, or some 'untaint' class,  
loop through the necessary fields -- pulling them from APR::Table,  
and validating/untainting them -- then just deal with those values.

Personally, I have a class that does this:
	Loop through values & validate
	valid data gets cleaned ( lead/trailing whitespace stripped, int()  
numerics ), and stored in an cleaned hash
	errors get marked in a hash that has an error code keyed to the field
	
	if scalar keys %errors :
		reprint form using the valid array as defaults
	else:
		do biz logic on the valid data




// Jonathan Vanasco

| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
- - - - - - - - - - - - - - - -



Re: $reg->param, $req->body - is there a way to set form data?

Posted by "Philip M. Gollucci" <pg...@p6m7g8.com>.
Patrick Galbraith wrote:
> Hi all,
> 
> I have in my code what used to work on 1.0. I have this variable, $form, 
> which is a reference for $req->param. I had cases in the code where 
> something is submitted in a form that is incorrect, and I want to change 
> the op of the form by setting $form->{op} (the code has a hash reference 
> to different subroutines that are keyed by op's value). Now when I do 
> this, I get this error:
> 
> Can't locate object method "STORE" via package 
> "APR::Request::Param::Table" at 
> /var/www/perl-lib/WebLib/Application/UserReg.pm line 360.\n, referer: 
> http://www.patg.net/userreg
You can not, they are readonly versions of APR::Table (apr_table_t)

You could always copy the structure to a hash somewhere.  Also, check the archvies of this
list, I know someone (probably joes) posted an answer to this question before.

-- 
------------------------------------------------------------------------
Philip M. Gollucci (pgollucci@p6m7g8.com) 323.219.4708
Consultant / http://p6m7g8.net/Resume/resume.shtml
Senior Software Engineer - TicketMaster - http://ticketmaster.com
1024D/A79997FA F357 0FDD 2301 6296 690F  6A47 D55A 7172 A799 97F

When I call your name, Girl, it starts to flame
Burning in my heart, Tearing it all apart..
No matter how I try My love I cannot hide....