X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=lib%2FCGI%2FEx%2FApp.pm;h=4a62f920b390b9228abc345090b23c1429e0415b;hb=48c4840be1f154e262de2c161cb86dc5000dfe47;hp=313baf443e4d25e47be64591390dd0c66b205ba1;hpb=a8620142ba0dcda3f0c5f102f791df944ed2245e;p=chaz%2Fp5-CGI-Ex diff --git a/lib/CGI/Ex/App.pm b/lib/CGI/Ex/App.pm index 313baf4..4a62f92 100644 --- a/lib/CGI/Ex/App.pm +++ b/lib/CGI/Ex/App.pm @@ -10,7 +10,7 @@ use strict; use vars qw($VERSION); BEGIN { - $VERSION = '2.01'; + $VERSION = '2.05'; Time::HiRes->import('time') if eval {require Time::HiRes}; } @@ -382,6 +382,8 @@ sub run_hook { my ($code, $found) = @{ $self->find_hook($hook, $step) }; if (! $code) { croak "Could not find a method named ${step}_${hook} or ${hook}"; + } elsif (! UNIVERSAL::isa($code, 'CODE')) { + croak "Value for $hook ($found) is not a code ref ($code)"; } ### record history @@ -757,15 +759,17 @@ sub print { sub print_out { my ($self, $step, $out) = @_; - $self->cgix->print_content_type(); + $self->cgix->print_content_type; print $out; } sub swap_template { my ($self, $step, $file, $swap) = @_; - require CGI::Ex::Template; my $args = $self->run_hook('template_args', $step); + $args->{'INCLUDE_PATH'} ||= sub { $self->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"" }; + + require CGI::Ex::Template; my $t = CGI::Ex::Template->new($args); my $out = ''; @@ -774,13 +778,7 @@ sub swap_template { return $out; } -sub template_args { - my $self = shift; - my $step = shift; - return { - INCLUDE_PATH => sub { $self->base_dir_abs || die "Could not find base_dir_abs while looking for template INCLUDE_PATH on step \"$step\"" }, - }; -} +sub template_args { {} } sub fill_template { my ($self, $step, $outref, $fill) = @_; @@ -936,9 +934,9 @@ sub hash_validation { if (ref($file) && ! UNIVERSAL::isa($file, 'SCALAR')) { $hash = $file; - ### read the file - if it fails - errors should be in the webserver error logs + ### read the file - if it is not found, errors will be in the webserver logs (all else dies) } elsif ($file) { - $hash = eval { $self->vob->get_validation($file) } || {}; + $hash = $self->vob->get_validation($file) || {}; } else { $hash = {};