Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
We don't bite newbies here... much
 
PerlMonks  

mod_perl 2 migration problems

by johnnywang (Priest)
on Sep 14, 2006 at 14:57 UTC ( #572939=perlquestion: print w/ replies, xml ) Need Help??
johnnywang has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I'm trying to migrate some existing mod_perl 1 code to mod_perl 2. The original code uses many calls like:
my $value = $r->args->{'foo'}; $r->args->{'foo'} = "bar";
to get and set request parameters. I couldn't seem to find an equivalent in mod_perl 2, Apache2::Request allows retrieving parameters by its param() method, but no way to set the parameters to be processed further down the chain, thanks.

Comment on mod_perl 2 migration problems
Download Code
Re: mod_perl 2 migration problems
by perrin (Chancellor) on Sep 14, 2006 at 16:35 UTC
    What you're doing here (changing the actual input) is kind of a bad idea. It would be better to use some kind of internal data structure for passing around your processed parameters, maybe storing them in a hash in $r->pnotes().
      well, yes, but I'm working with someone else's code, and can't really re-write everything at the moment.
        Well, you have to change code that uses $r->args to parse the query string because that doesn't work anymore. See the porting doc for more info. You can set the complete query string with $r->args(), which might allow later code to see your parameter changes, or you might be able to use Apache2::Request and modify the params using the APR::Table API on the object it returns when you call it like this:
        my $table = $req->param;
        I'm not sure those changes are visible to anyone else though.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://572939]
Approved by ww
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2014-04-18 22:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (472 votes), past polls