+sub do_edit :Exported {
+ my ($self, $r) = @_;
+ my $h = CGI::Untaint->new(%{$r->{params}});
+ my $obj;
+ if (@{$r->{args}}) {
+ # We have something to edit
+ $obj = $self->retrieve($r->{args}[0]);
+ $obj->update_from_cgi($h);
+ warn "Updating an object ($obj) with ".Dumper($h); use Data::Dumper;
+ } else {
+ $obj = $self->create_from_cgi($h);
+ }
+ if (my %errors = $obj->cgi_update_errors) {
+ # Set it up as it was:
+ warn "There were errors: ".Dumper(\%errors)."\n";
+ $r->{template_args}{cgi_params} = \%params;
+ $r->{template_args}{errors} = \%errors;
+ $r->{template} = "edit";
+ } else {
+ $r->{template} = "view";
+ }
+ return $obj;
+}
+
+sub adopt {
+ my ($self, $child) = @_;
+ $child->autoupdate(1);
+ $child->columns( Stringify => qw/ name / );
+}
+