]> git.decadent.org.uk Git - maypole.git/blobdiff - lib/Maypole/Model/CDBI.pm
updated MANIFEST
[maypole.git] / lib / Maypole / Model / CDBI.pm
index a200fc5851d174dffb6e2b86dff92311ac9fedda..ae11c4dc1fc50d2d498d5515c93e9a16e262cccd 100644 (file)
@@ -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;
@@ -36,6 +36,8 @@ use Class::DBI::Pager;
 use Lingua::EN::Inflect::Number qw(to_PL);
 use attributes ();
 
+use Data::Dumper;
+
 ###############################################################################
 # Helper methods
 
@@ -98,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] : []);
 }
 
@@ -112,7 +118,8 @@ sub _do_update_or_create {
 
   my $fatal;
   my $creating = 0;
-  my $h = CGI::Untaint::Maypole->new( %{$r->params} );
+
+  my $h = CGI::Untaint->new( %{$r->params} );
 
   # update or create
   if ($obj) {
@@ -133,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++;
   }
@@ -170,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);
@@ -580,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;
 }