[Maypole] Re: Maypole Dies when Triggered by Class::DBI Constraints

Robert James Kaes rjkaes@users.sourceforge.net
Mon, 28 Jun 2004 21:21:05 -0400


On Tue, 29 Jun 2004, Yuval Kogman wrote:
> On Mon, Jun 28, 2004 at 14:05:46 -0400, Robert James Kaes wrote:
> > My model (Class::DBI derived classes) have constraints added to some of
> > the columns.  The Class::DBI::FromCGI module correctly handles any
> > fields listed in the untaint_columns() method, but it's dying whenever
> > a constraint fails.
> 
> Funny, when i have errors like that the input is returned to me,
> reddenned.. Are you running Maypole 1.5? I think it had some
> improvements with error handling.

Yes, I am running Maypole 1.5.  Also, invalid columns mentioned in my
__PACKAGE__->untaint_columns() method are returned in the
$r->{template_args}{errors} variable, as they should be.  The problem
is actually with constraints using the Class::DBI
__PACKAGE__->constrain_column() method (or in my case the
__PACKAGE__->add_constraint() method.)

To take an example, I have a:

  __PACKAGE__->add_constraint('valid_dates', finish => \&check_dates);

call in my model class.  The check_dates() function checks two fields
to ensure that one field has a latter date than the other field.  Both
"start" and "finish" fields are valid dates, so they passed my
untaint_columns() check, but if the "finish" date is earlier than the
"start" date, the "valid_dates" constraint fails.  This is not being
reported to my application in any way (since I believe the Class::DBI
module uses a croak method to report the failure.)

The question then becomes: is this a Class::DBI::FromCGI problem?
Should it check for failed constraints and catch the error (via an
eval perhaps) and then report that information via the
cgi_update_errors() method?  Or should Maypole's do_edit() method
catch the error and set the $r->{template_args}{errors} variable with
the information?

Basically, valid model constraints are not reported (or even caught)
and this causes my Maypole based application to fail.

Thanks for any help you can provide.
        -- Robert

-- 
    Robert James Kaes    ---  Flarenet Inc.  ---    (519) 426-3782
		 http://www.flarenet.com/consulting/
      * Putting the Service Back in Internet Service Provider *