Mercurial > pub > Impl
comparison Lib/IMPL/Web/QueryHandler/UrlController.pm @ 194:4d0e1962161c
Replaced tabs with spaces
IMPL::Web::View - fixed document model, new features (control classes, document constructor parameters)
author | cin |
---|---|
date | Tue, 10 Apr 2012 20:08:29 +0400 |
parents | d1676be8afcc |
children |
comparison
equal
deleted
inserted
replaced
193:8e8401c0aea4 | 194:4d0e1962161c |
---|---|
6 use IMPL::Exception; | 6 use IMPL::Exception; |
7 use Carp qw(croak); | 7 use Carp qw(croak); |
8 use Scalar::Util qw(tainted); | 8 use Scalar::Util qw(tainted); |
9 | 9 |
10 BEGIN { | 10 BEGIN { |
11 public property namespace => prop_all; | 11 public property namespace => prop_all; |
12 } | 12 } |
13 | 13 |
14 __PACKAGE__->PassThroughArgs; | 14 __PACKAGE__->PassThroughArgs; |
15 | 15 |
16 sub Process { | 16 sub Process { |
17 my ($this,$action,$nextHandler) = @_; | 17 my ($this,$action,$nextHandler) = @_; |
18 | 18 |
19 my $namespace = $this->namespace || $action->application->typeof; | 19 my $namespace = $this->namespace || $action->application->typeof; |
20 | 20 |
21 my @target = grep $_, split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("No target specified"); | 21 my @target = grep $_, split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("No target specified"); |
22 | 22 |
23 my $method = pop @target; | 23 my $method = pop @target; |
24 if ( $method =~ /^(\w+)/ ) { | 24 if ( $method =~ /^(\w+)/ ) { |
25 $method = $1; | 25 $method = $1; |
26 } else { | 26 } else { |
27 die new IMPL::Exception("Invalid method name",$method); | 27 die new IMPL::Exception("Invalid method name",$method); |
28 } | 28 } |
29 | 29 |
30 (/^(\w+)$/ or die new IMPL::Exception("Invalid module name part", $_)) and $_=$1 foreach @target; | 30 (/^(\w+)$/ or die new IMPL::Exception("Invalid module name part", $_)) and $_=$1 foreach @target; |
31 | 31 |
32 my $module = join '::',$namespace,@target; | 32 my $module = join '::',$namespace,@target; |
33 | 33 |
34 die new IMPL::Exception("A module name is untrusted", $module) if tainted($module); | 34 die new IMPL::Exception("A module name is untrusted", $module) if tainted($module); |
35 | 35 |
36 eval "require $module; 1;" unless eval{ $module->can('InvokeAction'); }; | 36 eval "require $module; 1;" unless eval{ $module->can('InvokeAction'); }; |
37 if (my $err = $@ ) { | 37 if (my $err = $@ ) { |
38 die new IMPL::Exception("Failed to load module",$module,$err); | 38 die new IMPL::Exception("Failed to load module",$module,$err); |
39 } | 39 } |
40 | 40 |
41 if(UNIVERSAL::can($module,'InvokeAction')) { | 41 if(UNIVERSAL::can($module,'InvokeAction')) { |
42 $module->InvokeAction($method,$action); | 42 $module->InvokeAction($method,$action); |
43 } else { | 43 } else { |
44 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method); | 44 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method); |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 1; | 48 1; |
49 | 49 |
50 __END__ | 50 __END__ |