X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=lib%2FMaypole%2FModel%2FCDBI.pm;h=ae11c4dc1fc50d2d498d5515c93e9a16e262cccd;hb=02b642b7100a6e0a91e83aca3c4e63cd88786315;hp=5d3bebec2b39ae4f9e77ac61040c937e389e12c8;hpb=43c32b954aa111a98b2d886f0f9c4cf18fe8dd3c;p=maypole.git diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 5d3bebe..ae11c4d 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -25,7 +25,7 @@ will instead use Class::DBI classes provided. use base qw(Maypole::Model::Base Class::DBI); use Maypole::Model::CDBI::AsForm; -use CGI::Untaint::Maypole; +use CGI::Untaint; use Class::DBI::Plugin::Type; use Class::DBI::FromCGI; use Class::DBI::Loader; @@ -100,11 +100,15 @@ sub do_edit : Exported { } undef $obj if $creating; + + die "do_update failed with error : $fatal" if ($fatal); $r->template("edit"); } else { $r->template("view"); } + + $r->objects( $obj ? [$obj] : []); } @@ -136,7 +140,10 @@ sub _do_update_or_create { }; if ($fatal = $@) { - warn "$fatal" if $r->debug; + warn "FATAL ERROR: $fatal" if $r->debug; +# $self->dbi_rollback; + } else { +# $self->dbi_commit; } $creating++; } @@ -173,7 +180,9 @@ sub delete : Exported { sub do_delete { my ( $self, $r ) = @_; + # FIXME: handle fatal error with exception $_->SUPER::delete for @{ $r->objects || [] }; +# $self->dbi_commit; $r->objects( [ $self->retrieve_all ] ); $r->{template} = "list"; $self->list($r); @@ -583,7 +592,9 @@ sub setup_database { ); $config->{classes} = [ $config->{loader}->classes ]; $config->{tables} = [ $config->{loader}->tables ]; - warn( 'Loaded tables: ' . join ',', @{ $config->{tables} } ) + + my @table_class = map { $_ . " => " . $config->{loader}->_table2class($_) } @{ $config->{tables} }; + warn( 'Loaded tables to classes: ' . join ', ', @table_class ) if $namespace->debug; }