[Catalyst] Re: retrieving multiple values from forms
Matt S Trout
dbix-class at trout.me.uk
Tue Dec 18 17:49:53 GMT 2007
On Mon, Dec 17, 2007 at 07:26:53PM -0600, Andrew Rodland wrote:
> On Monday 17 December 2007 05:27:46 pm A. Pagaltzis wrote:
> > The *sane* thing is neither.
> >
> > The sane thing is to have *TWO* methods, one that *always*
> > returns a scalar, and one that *always* returns a list. (Or
> > rather, an arrayref, because if it’s just a list, it is easy to
> > improperly treat it like a scalar, whereas if it’s an arrayref
> > it’s impossible to forget to unpack the array when you meant to
> > do that.)
> >
> > Then you can say what you mean, you can say it *easily* either
> > way, and the result is always completely determined by what the
> > code says and not at all by what the data looks like. Sanity.
>
> Yeah, I can agree with this. I realized the same thing myself... after posting
> my original message of course. Teach me to wait a bit longer before hitting
> send in the future. Anyway yeah, what I really want is "param_list"
> or "param_aref", without any of the actual "CGI compat" of param -- param
> just comes closer to my goal than params. Not sure what the ideal behavior
> for the "only one" version would be, but params is at least practical. If you
> see ARRAY(0xbadfad) where you expected useful data it's not that hard to
> trace back and see what you did wrong.
Exactly my point. Except you should ideally use query_params and body_params
explicitly in most cases; it's fairly rare that you don't know which is which.
I'd love to see a patch for say 'query_value', 'query_array', plus body_* and
any_param_* methods (names made up on the spot and neither final nor necessarily
even any good :)
--
Matt S Trout Need help with your Catalyst or DBIx::Class project?
Technical Director http://www.shadowcat.co.uk/catalyst/
Shadowcat Systems Ltd. Want a managed development or deployment platform?
http://chainsawblues.vox.com/ http://www.shadowcat.co.uk/servers/
More information about the Catalyst
mailing list