(Dagfinn Ilmari Mannsåker)
- Added $r->headers_in & $r->headers_out (request & response headers)
- Split the meat of the view template off to a view_item macro.
- - Prefix warn() in M::V::Base with error description
+ - #7643 - improve M::V::Base's error() messages. prefix error with label,
+ and carp()
- #7651 - minor POD improvements in M::M::CDBI (Dave Howorth)
- #7834 - minor POD update in M::M::CDBI (Kevin Connor)
- default search action removes empty fields from search parameters
- - Maypole::Application will create a separate Maypole::Config for each
- application (instead of the current workaround for multiple apps under
- mod_perl)
+ - #6622 - Maypole::Application will create a separate Maypole::Config for
+ each application (instead of the current workaround for multiple apps
+ under mod_perl)
+ - #7917 - if do_edit fails for object creation, try again with the correct
+ template (addnew)
+ - #7930 - handle Class::DBI constraint failures in do_edit.
- classmetadata template variables can now be overriden individually
- Template toolkit objects are configured with Maypole::Config->view_options
- Make test suite work with DBD::SQLite2
unless -e DATASOURCE;
eval "require DBD::SQLite";
if ($@) {
- eval "require DBD::SQLite2" && dbi_driver = 'SQLite2';
+ eval "require DBD::SQLite2" and $dbi_driver = 'SQLite2';
}
}
BeerDB->setup(join ':', "dbi", $dbi_driver, DATASOURCE);
my $h = CGI::Untaint->new( %{ $r->{params} } );
my $creating = 0;
my ($obj) = @{ $r->objects || [] };
+ my $fatal;
if ($obj) {
-
# We have something to edit
- $obj->update_from_cgi( $h =>
- { required => $r->{config}{ $r->{table} }{required_cols} || [], }
- );
+ eval {
+ $obj->update_from_cgi( $h =>
+ { required => $r->{config}{ $r->{table} }{required_cols} || [], }
+ );
+ };
+ $fatal = $@;
}
else {
- $obj =
- $self->create_from_cgi( $h =>
- { required => $r->{config}{ $r->{table} }{required_cols} || [], }
- );
+ eval {
+ $obj =
+ $self->create_from_cgi( $h =>
+ { required => $r->{config}{ $r->{table} }{required_cols} || [], }
+ );
+ };
+ $fatal = $@;
$creating++;
}
- if ( my %errors = $obj->cgi_update_errors ) {
+ if ( my %errors = $fatal ? (FATAL => $fatal) : $obj->cgi_update_errors ) {
# Set it up as it was:
$r->{template_args}{cgi_params} = $r->{params};
$r->{template_args}{errors} = \%errors;
- $r->{template} = "edit";
- undef $obj if $creating; # Couldn't create
+
+ if ($creating) {
+ undef $obj;
+ $r->template("addnew");
+ } else {
+ $r->template("edit");
+ }
}
else {
$r->{template} = "view";
use UNIVERSAL::moniker;
use strict;
use Maypole::Constants;
+use Carp;
sub new { bless {}, shift } # By default, do nothing.
sub error {
my ( $self, $r, $desc ) = @_;
$desc = $desc ? "$desc: " : "";
- warn $desc . $r->{error} ."\n";
+ carp $desc . $r->{error};
if ( $r->{error} =~ /not found$/ ) {
# This is a rough test to see whether or not we're a template or