[prev] [thread] [next] [Date index for 2005/06/20]
------=_Part_2463_13657686.1119298063527 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline (Crossposted to CDBI and DFV lists in the hope that someone has an answer) I'm trying to use Class::DBI::FromForm with a new application and am runnin= g=20 into consistent problems with the output from D::FV::Results::valid(). The= =20 problem arises in C::DBI::FromForm::_run_update(), specifically ~line 73: my $val =3D $results->valid($col); According to the docs, valid() returns a scalar in scalar context and an=20 array in list context. The problem is that the scalar value being returned= =20 is an array ref with a single value instead of the expected scalar. This=20 obviously causes problems when update() is called on my CDBI object. I've done a bit of debugging and can reproduce the problem. Here are the=20 steps: 1) Restart apache 2) Submit an edit version of the form 3) The first time around, update works w/o problems 4) Subsequent requests to an apache process give the errors. Below is the output from Data::Dumper on the Data::FormValidator::Results= =20 object. It seems that something may be getting accidentally cached. If you= =20 notice, the values for the 'valid' key start off being scalars, and end up= =20 as arrayrefs. This is running on mod_perl 1.2x, perl 5.005.003, and apache= =20 1.3.x. DFV and C::DBI::FromForm are latest off CPAN. The application uses= =20 CGI::Application 3.x. Here's the code in question: # in superclass... my $dfv =3D Data::FormValidator->new({}, $self->param('dfv_defaults') ); print STDERR "_form_submitted() Checking profile...\n"; my $r =3D $dfv->check($q, $profile); $self->param('dfv_results', $r); # in actual application code my $dfv_results =3D $self->param('dfv_results'); if ( my $id =3D $q->param('id') ) { $csr =3D My::Class->retrieve($id); $csr->update_from_form($dfv_results); } # first time around $VAR1 =3D bless( { 'unknown' =3D> { 'id' =3D> 26, 'action' =3D> 'edit' }, 'valid' =3D> { 'uid' =3D> 12345, 'signature' =3D> 'far.gif', 'role' =3D> 'network', 'last' =3D> 'Bar1', 'email' =3D> 'foo1@xxxxxxx.xxx', 'first' =3D> 'Foo1', 'photo' =3D> 'fd.jpg', 'active' =3D> '0', 'extension' =3D> 300 }, 'profile' =3D> { 'constraints' =3D> {}, 'defaults' =3D> {}, 'require_some' =3D> {}, 'field_filter_regexp_map' =3D> {}, 'required' =3D> [ 'first', 'last', 'email', 'extension', 'active', 'uid' ], 'msgs' =3D> { 'any_errors' =3D> 'some_errors', 'prefix' =3D> 'err_' }, 'constraint_regexp_map' =3D> {}, 'field_filters' =3D> {}, 'dependency_groups' =3D> {}, 'optional' =3D> [ 'photo', 'role', 'signature' ], 'dependencies' =3D> {} }, 'msgs' =3D> { 'any_errors' =3D> 'some_errors', 'prefix' =3D> 'err_' }, 'missing' =3D> {}, 'invalid' =3D> {}, '__INPUT_DATA' =3D> bless( { 'email' =3D> [ 'foo1@xxxxxxx.xxx' ], 'first' =3D> [ 'Foo1' ], '.charset' =3D> 'ISO-8859-1', 'role' =3D> [ 'network' ], 'signature' =3D> [ 'far.gif' ], 'photo' =3D> [ 'fd.jpg' ], 'uid' =3D> [ 12345 ], '.parameters' =3D> [ 'action', 'id', 'first', 'last', 'email', 'extension', 'uid', 'active', 'photo', 'signature', 'role' ], 'active' =3D> [ '0' ], 'last' =3D> [ 'Bar1' ], 'extension' =3D> [ 300 ], 'id' =3D> [ 26 ], '.path_info' =3D> '', '.fieldnames' =3D> {}, 'action' =3D> [ 'edit' ] }, 'CGI' ) }, 'Data::FormValidator::Results' ); # second go around - everything but 'valid' snipped and is the same 'valid' =3D> { 'first' =3D> [ 'Foo1' ], 'email' =3D> [ 'foo1@xxxxxxx.xxx' ], 'uid' =3D> [ 12345 ], 'role' =3D> [ 'network' ], 'active' =3D> [ '0' ], 'last' =3D> [ 'Bar1' ], 'extension' =3D> [ 300 ] }, Drew --=20 ---------------------------------------------------------------- Drew Taylor * Web development & consulting Email: drew@xxxxxxxxxx.xxx * Site implementation & hosting Web : www.drewtaylor.com <http://www.drewtaylor.com> *=20 perl/mod_perl/DBI/mysql/postgres ---------------------------------------------------------------- ------=_Part_2463_13657686.1119298063527 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline (Crossposted to CDBI and DFV lists in the hope that someone has an answer)<= br> <br> I'm trying to use Class::DBI::FromForm with a new application and am running into consistent problems with the output from D::FV::Results::valid(). The problem arises in C::DBI::FromForm::_run_update(), specifically ~line 73:<br> <br> my $val =3D $results->valid($col);<br> <br>According to the docs, valid() returns a scalar in scalar context and an array in list context. The problem is that the scalar value being returned is an array ref with a single value instead of the expected scalar. This obviously causes problems when update() is called on my CDBI object.<br> <br> I've done a bit of debugging and can reproduce the problem. Here are the st= eps:<br> 1) Restart apache<br> 2) Submit an edit version of the form<br> 3) The first time around, update works w/o problems<br> 4) Subsequent requests to an apache process give the errors.<br> <br> Below is the output from Data::Dumper on the Data::FormValidator::Results object. It seems that something may be getting accidentally cached. If you notice, the values for the 'valid' key start off being scalars, and end up as arrayrefs. This is running on mod_perl 1.2x, perl 5.005.003, and apache 1.3.x. DFV and C::DBI::FromForm are latest off CPAN. The application uses CGI::Application 3.x.<br> <br> Here's the code in question:<br> # in superclass...<br> my $dfv =3D Data::FormValidator->new({}, $self->param('dfv_defaults')= );<br> print STDERR "_form_submitted() Checking profile...\n";<br> my $r =3D $dfv->check($q, $profile);<br> $self->param('dfv_results', $r);<br> <br> # in actual application code<br> my $dfv_results =3D $self->param('dfv_results');<br> if ( my $id =3D $q->param('id') ) {<br> $csr =3D My::Class->retrieve($id);<br> $csr->update_from_form($dfv_results);<br> }<br> <br> # first time around<br> $VAR1 =3D bless( {<br> &nb= sp; 'unknown' =3D> {<br> &nb= sp; = 'id' =3D> 26,<br> &nb= sp; = 'action' =3D> 'edit'<br> &nb= sp; = },<br> &nb= sp; 'valid' =3D> {<br> &nb= sp; = 'uid' =3D> 12345,<br> &nb= sp; = 'signature' =3D> 'far.gif',<br> &nb= sp; = 'role' =3D> 'network',<br> &nb= sp; = 'last' =3D> 'Bar1',<br> &nb= sp; = 'email' =3D> '<a href=3D"mailto:foo1@xxxxxxx.xxx">foo1@xxxxxxx.xxx</a>',= <br> &nb= sp; = 'first' =3D> 'Foo1',<br> &nb= sp; = 'photo' =3D> 'fd.jpg',<br> &nb= sp; = 'active' =3D> '0',<br> &nb= sp; = 'extension' =3D> 300<br> &nb= sp; = },<br> &nb= sp; 'profile' =3D> {<br> &nb= sp; = 'constraints' =3D> {},<br> &nb= sp; = 'defaults' =3D> {},<br> &nb= sp; = 'require_some' =3D> {},<br> &nb= sp; = 'field_filter_regexp_map' =3D> {},<br> &nb= sp; = 'required' =3D> [<br> &nb= sp; = &nb= sp; 'first',<br> &nb= sp; = &nb= sp; 'last',<br> &nb= sp; = &nb= sp; 'email',<br> &nb= sp; = &nb= sp; 'extension',<br> &nb= sp; = &nb= sp; 'active',<br> &nb= sp; = &nb= sp; 'uid'<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'msgs' =3D> {<br> &nb= sp; = &nb= sp; 'any_errors' =3D> 'some_errors',<br> &nb= sp; = &nb= sp; 'prefix' =3D> 'err_'<br> &nb= sp; = &nb= sp; },<br> &nb= sp; = 'constraint_regexp_map' =3D> {},<br> &nb= sp; = 'field_filters' =3D> {},<br> &nb= sp; = 'dependency_groups' =3D> {},<br> &nb= sp; = 'optional' =3D> [<br> &nb= sp; = &nb= sp; 'photo',<br> &nb= sp; = &nb= sp; 'role',<br> &nb= sp; = &nb= sp; 'signature'<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'dependencies' =3D> {}<br> &nb= sp; = },<br> &nb= sp; 'msgs' =3D> {<br> &nb= sp; = 'any_errors' =3D> 'some_errors',<br> &nb= sp; = 'prefix' =3D> 'err_'<br> &nb= sp; = },<br> &nb= sp; 'missing' =3D> {},<br> &nb= sp; 'invalid' =3D> {},<br> &nb= sp; '__INPUT_DATA' =3D> bless( {<br> &nb= sp; = &nb= sp; 'email' =3D> [<br> &nb= sp; = &nb= sp; = '<a href=3D"mailto:foo1@xxxxxxx.xxx">foo1@xxxxxxx.xxx</a>'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'first' =3D> [<br> &nb= sp; = &nb= sp; = 'Foo1'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; '.charset' =3D> 'ISO-8859-1',<br> &nb= sp; = &nb= sp; 'role' =3D> [<br> &nb= sp; = &nb= sp; = 'network'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'signature' =3D> [<br> &nb= sp; = &nb= sp; = 'far.gif'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'photo' =3D> [<br> &nb= sp; = &nb= sp; = 'fd.jpg'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'uid' =3D> [<br> &nb= sp; = &nb= sp; = 12345<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; '.parameters' =3D> [<br> &nb= sp; = &nb= sp; = 'action',<br> &nb= sp; = &nb= sp; = 'id',<br> &nb= sp; = &nb= sp; = 'first',<br> &nb= sp; = &nb= sp; = 'last',<br> &nb= sp; = &nb= sp; = 'email',<br> &nb= sp; = &nb= sp; = 'extension',<br> &nb= sp; = &nb= sp; = 'uid',<br> &nb= sp; = &nb= sp; = 'active',<br> &nb= sp; = &nb= sp; = 'photo',<br> &nb= sp; = &nb= sp; = 'signature',<br> &nb= sp; = &nb= sp; = 'role'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'active' =3D> [<br> &nb= sp; = &nb= sp; = '0'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'last' =3D> [<br> &nb= sp; = &nb= sp; = 'Bar1'<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'extension' =3D> [<br> &nb= sp; = &nb= sp; = 300<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; 'id' =3D> [<br> &nb= sp; = &nb= sp; = 26<br> &nb= sp; = &nb= sp; = ],<br> &nb= sp; = &nb= sp; '.path_info' =3D> '',<br> &nb= sp; = &nb= sp; '.fieldnames' =3D> {},<br> &nb= sp; = &nb= sp; 'action' =3D> [<br> &nb= sp; = &nb= sp; = 'edit'<br> &nb= sp; = &nb= sp; = ]<br> &nb= sp; = &nb= sp; }, 'CGI' )<br> &nb= sp; }, 'Data::FormValidator::Results' );<br> <br> # second go around - everything but 'valid' snipped and is the same<br> &nb= sp; 'valid' =3D> {<br> &nb= sp; = 'first' =3D> [<br> &nb= sp; = &nb= sp; 'Foo1'<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'email' =3D> [<br> &nb= sp; = &nb= sp; '<a href=3D"mailto:foo1@xxxxxxx.xxx">foo1@xxxxxxx.xxx</a>'<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'uid' =3D> [<br> &nb= sp; = &nb= sp; 12345<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'role' =3D> [<br> &nb= sp; = &nb= sp; 'network'<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'active' =3D> [<br> &nb= sp; = &nb= sp; '0'<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'last' =3D> [<br> &nb= sp; = &nb= sp; 'Bar1'<br> &nb= sp; = &nb= sp; ],<br> &nb= sp; = 'extension' =3D> [<br> &nb= sp; = &nb= sp; 300<br> &nb= sp; = &nb= sp; ]<br> &nb= sp; = },<br> <br> Drew<br>-- <br>------------------------------------------------------------= ----<br> Drew Taylor &nb= sp; * Web development & consulting<br> Email: <a href=3D"mailto:= drew@xxxxxxxxxx.xxx">drew@xxxxxxxxxx.xxx</a> * Site i= mplementation & hosting<br> Web : <a href=3D"http://www.drew= taylor.com">www.drewtaylor.com</a> * perl/mod_perl/D= BI/mysql/postgres <br> ---------------------------------------------------------------- ------=_Part_2463_13657686.1119298063527--
Problem with Class::DBI::FromForm & Data::FormValidator
|
Re: Problem with Class::DBI::FromForm & Data::FormValidator
|
Re: Problem with Class::DBI::FromForm & Data::FormValidator
|
Generated at 16:35 on 28 Jul 2005 by mariachi v0.52