From 8fbe91d3208f182f78e2cd316f2c0c7a5c76edb8 Mon Sep 17 00:00:00 2001 From: Simon Cozens Date: Mon, 24 Jan 2005 20:05:54 +0000 Subject: [PATCH] fix M::M::Base::FETCH_CODE_ATTRIBUTES, warn() about CDBI::FromCGI errors, fix array length test in factory/edit template git-svn-id: http://svn.maypole.perl.org/Maypole/trunk@333 48953598-375a-da11-a14b-00016c27c3ee --- Changes | 5 ++++- lib/Maypole/Model/Base.pm | 4 ++-- lib/Maypole/Model/CDBI.pm | 6 ++++-- templates/factory/edit | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Changes b/Changes index a05fbc6..96caa5d 100644 --- a/Changes +++ b/Changes @@ -2,7 +2,7 @@ This file documents the revision history for Perl extension Maypole. For information about current developments and future releases, see: http://maypole.perl.org/?TheRoadmap -2.07 Sun Jan 16 18:45:00 2005 +2.07 Mon Jan 24 20:00:00 2005 Internal changes: - Removed Maypole::Model->description. It didn't work as expected and clashed with 'description' columns in the database @@ -12,6 +12,9 @@ For information about current developments and future releases, see: undefined element - Fixed overriding $r->template_args->{classmetadata} in M::V::Base (Thanks to Dave Howorth for spotting the mistake) + - FETCH_CODE_ATRIBUTES in M::M::Base should return an empty list if there + are no attributes + - M::M::CDBI will warn() about Class::DBI::FromCGI errors - #9473: Maypole::Model::CDBI->related_class (Thanks David Baird) - #9434: M::M::CDBI->search generated "uninitialized value" warnings diff --git a/lib/Maypole/Model/Base.pm b/lib/Maypole/Model/Base.pm index 678c399..3b7c58b 100644 --- a/lib/Maypole/Model/Base.pm +++ b/lib/Maypole/Model/Base.pm @@ -7,7 +7,7 @@ our %remember; sub MODIFY_CODE_ATTRIBUTES { $remember{ $_[1] } = $_[2]; () } -sub FETCH_CODE_ATTRIBUTES { $remember{ $_[1] } } +sub FETCH_CODE_ATTRIBUTES { $remember{ $_[1] } || () } sub process { my ( $class, $r ) = @_; @@ -180,7 +180,7 @@ sub is_public { my ( $self, $action ) = @_; my $cv = $self->can($action); return 0 unless $cv; - my $attrs = join " ", attributes::get($cv); + my $attrs = join " ", (attributes::get($cv) || ()); do { warn "$action not exported" if Maypole->debug; return 0; diff --git a/lib/Maypole/Model/CDBI.pm b/lib/Maypole/Model/CDBI.pm index 4ed0aa6..a02f36f 100644 --- a/lib/Maypole/Model/CDBI.pm +++ b/lib/Maypole/Model/CDBI.pm @@ -119,7 +119,9 @@ sub do_edit : Exported { { required => $r->{config}{ $r->{table} }{required_cols} || [], } ); }; - $fatal = $@; + if ($fatal = $@) { + warn "$fatal" if $r->debug; + } $creating++; } if ( my %errors = $fatal ? (FATAL => $fatal) : $obj->cgi_update_errors ) { @@ -134,7 +136,7 @@ sub do_edit : Exported { else { $r->{template} = "view"; } - $r->objects( [$obj] ); + $r->objects( $obj ? [$obj] : []); } sub delete : Exported { diff --git a/templates/factory/edit b/templates/factory/edit index d114897..a7c6630 100644 --- a/templates/factory/edit +++ b/templates/factory/edit @@ -11,7 +11,7 @@ form similar to L but with the current values filled in. [% PROCESS macros %] [% INCLUDE header %] [% INCLUDE title %] -[% IF objects.length %] +[% IF objects.size %]
Edit a [% classmetadata.moniker %]
[% FOR item = objects; %]
-- 2.39.5