On Mon, Apr 26, 2010 at 11:59 PM, Aristotle Pagaltzis <[email protected]> wrote: > * Zbigniew Lukasiak <[email protected]> [2010-04-26 12:25]: >> This is a fine advice - but unfortunately the ->param method >> call suffers from additional problem - which is described in >> much detail in the documentation (go to the NOTE at: >> http://search.cpan.org/~bobtfish/Catalyst-Runtime-5.80022/lib/Catalyst/Request.pm#$req-%3Eparam). > > Yeah, but the ->params hash has the converse problem: if you > write > > $c->model->insert_person( name => $c->req->params->{'name'} ) > > then you may be surprised to find out there are people with name > like ARRAY(0xDEADBEEF). Of course that’s just a relatively minor > case of data corruption. Worse is if you legitimately expect > a parameter to have one or more values, eg. a pile of checkboxes. > Then you have to constantly check whether you’re getting a scalar > or an array reference. > > So either you use the legacy method and have to protect against > getting more values than you wanted, or you use the suggested > method and have to protect against getting fewer values than you > expect in the general case. > > I briefly tried to write something to stick Hash::MultiValue into > Catalyst to end the madness, but doing it properly would require > a plugin, plus HTTP::BodyParser (I think) was using a misdesigned > approach that made deep integration of H::MV impossible (with > properly preserved k/v pair order). > > Could have written a Request role… but that seemed unsatisfying. > > I wonder whether it would be possible to rip out the respective > bits from Cat and use just H::MV, and leave the current stuff to > a compat plugin or something like that…
Not a very concrete answer - but I remember that Miyagawa talked about fixing that in Plack::Request (and I am not sure but I think it also involved H::MV) - so there might be some occasion for reuse :) Cheers, Z. > > Regards, > -- > Aristotle Pagaltzis // <http://plasmasturm.org/> > > _______________________________________________ > List: [email protected] > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/[email protected]/ > Dev site: http://dev.catalyst.perl.org/ > -- Zbigniew Lukasiak http://brudnopis.blogspot.com/ http://perlalchemy.blogspot.com/ _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
