comparison Lib/IMPL/Web/QueryHandler/UrlController.pm @ 139:5a9f64890c31

Fixed module loading by the UriController
author wizard
date Thu, 01 Jul 2010 17:32:29 +0400
parents c13a215508ca
children e6447ad85cb4
comparison
equal deleted inserted replaced
138:c5bc900eefd3 139:5a9f64890c31
2 use strict; 2 use strict;
3 use base qw(IMPL::Web::QueryHandler); 3 use base qw(IMPL::Web::QueryHandler);
4 4
5 use IMPL::Class::Property; 5 use IMPL::Class::Property;
6 use IMPL::Exception; 6 use IMPL::Exception;
7 use Carp; 7 use Carp qw(croak);
8 8
9 BEGIN { 9 BEGIN {
10 public property namespace => prop_all; 10 public property namespace => prop_all;
11 } 11 }
12 12
22 my $method = pop @target; 22 my $method = pop @target;
23 $method =~ s/\.\w+$//; 23 $method =~ s/\.\w+$//;
24 24
25 my $module = join '::',$namespace,@target; 25 my $module = join '::',$namespace,@target;
26 26
27 eval "require $module; 1;" unless $INC{$module}; 27 eval "require $module; 1;" unless eval{ $module->can('InvokeAction'); };
28 carp $@ if $@; 28 if (my $err = $@ ) {
29 die new IMPL::Exception("Failed to load module",$module,$err);
30 }
29 31
30 if(UNIVERSAL::can($module,'InvokeAction')) { 32 if(UNIVERSAL::can($module,'InvokeAction')) {
31 $module->InvokeAction($method,$action); 33 $module->InvokeAction($method,$action);
32 } else { 34 } else {
33 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method); 35 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method);