RE: Separating GET and POST parameters

"Carmichael, Lee" <[email protected]> Mon, 8 Aug 2005 10:57:33 -0500
Newsgroups gmane.comp.web.mason.devel
Message-ID <28D0F19E982F6046A05985EE70AED6E7014D33F7@s228130hz1ew09.apptix-01.savvis.net>
Hello Jeremy,

< Sorry everyone for a 'users' post to the 'devel' list but I wanted to
follow the thread for future folks. >

Why not just use 'MasonX::WebApp' and add two new methods like
'args_get' and 'args_post' that return hash ref of the correct stuff? 

It could look something like this:

package My::WebApp;

use base "MasonX::WebApp";

## you wouldn't want something confusing like
## get_args since that looks like a getter... 
sub args_get 
{
   my %g = $_[0]->apache_req->args;
   return \%g;
}

sub args_post
{
   my $self = shift;
   my %post;

   foreach my $k (keys(%{$self->args})) {
      next if $self->args_get->{$k};
      $post{$k} = $self->args->{$k};     
   }
   
   return \%post;
}


In the mason env, you would just do (below) or just add a global
variable for both of these hashes:

<%init>
   my %GETARGS = %{$WebApp->args_get}; 
   my %POSTARGS = %{$WebApp->args_post};
</%init>

I haven't test or tried any of these but maybe this will get you going.
You could also use 'Apache::Request->instance' in a custom apache
handler then in this use that to process the '$r->content' yourself for
the post parameters. 


Just a couple of ideas,

Lee


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf