Mercurial > pub > Impl
annotate Lib/IMPL/Web/QueryHandler/UrlController.pm @ 148:e6447ad85cb4
DOM objects now have a schema and schemaSource properties
RegExp now can launder data
Improved post to DOM transformation (multiple values a now supported)
Added new axes to navigation queries: ancestor and descendant
minor changes and bug fixes
author | wizard |
---|---|
date | Mon, 16 Aug 2010 08:26:44 +0400 |
parents | 5a9f64890c31 |
children | 3f09584bf189 |
rev | line source |
---|---|
110 | 1 package IMPL::Web::QueryHandler::UrlController; |
97 | 2 use strict; |
3 use base qw(IMPL::Web::QueryHandler); | |
4 | |
5 use IMPL::Class::Property; | |
6 use IMPL::Exception; | |
139 | 7 use Carp qw(croak); |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
8 use Scalar::Util qw(tainted); |
97 | 9 |
10 BEGIN { | |
11 public property namespace => prop_all; | |
12 } | |
13 | |
14 __PACKAGE__->PassThroughArgs; | |
15 | |
16 sub Process { | |
17 my ($this,$action,$nextHandler) = @_; | |
18 | |
19 my $namespace = $this->namespace || $action->application->type; | |
20 | |
21 my @target = grep $_, split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("No target specified"); | |
22 | |
23 my $method = pop @target; | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
24 if ( $method =~ /^(\w+)/ ) { |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
25 $method = $1; |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
26 } else { |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
27 die new IMPL::Exception("Invalid method name",$method); |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
28 } |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
29 |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
30 (/^(\w+)$/ or die new IMPL::Exception("Invalid module name part", $_)) and $_=$1 foreach @target; |
97 | 31 |
32 my $module = join '::',$namespace,@target; | |
33 | |
148
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
34 die new IMPL::Exception("A module name is untrusted", $module) if tainted($module); |
e6447ad85cb4
DOM objects now have a schema and schemaSource properties
wizard
parents:
139
diff
changeset
|
35 |
139 | 36 eval "require $module; 1;" unless eval{ $module->can('InvokeAction'); }; |
37 if (my $err = $@ ) { | |
38 die new IMPL::Exception("Failed to load module",$module,$err); | |
39 } | |
97 | 40 |
41 if(UNIVERSAL::can($module,'InvokeAction')) { | |
42 $module->InvokeAction($method,$action); | |
43 } else { | |
44 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method); | |
45 } | |
46 } | |
47 | |
110 | 48 1; |
49 | |
50 __END__ | |
51 | |
52 =pod | |
53 | |
54 =head1 NAME | |
55 | |
56 C<IMPL::Web::QueryHandler::UrlController> - вызов метода на основе <url> запроса. | |
57 | |
58 =head1 DESCRIPTION | |
59 | |
60 Использует переменную C<$ENV{PATH_INFO}> для получения имени и метода модуля. | |
61 | |
62 =cut |