annotate Lib/IMPL/Web/QueryHandler/UrlController.pm @ 144:b56ebc31bf18

Empty nodes no more created while transforming a post request to the DOM document minor speed improvements to the object CTOR caching Added support for a secure processing (and 'laundering' ) a CGI parameters Many minor fixes
author wizard
date Tue, 13 Jul 2010 02:05:38 +0400
parents 5a9f64890c31
children e6447ad85cb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
110
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
1 package IMPL::Web::QueryHandler::UrlController;
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
2 use strict;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
3 use base qw(IMPL::Web::QueryHandler);
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
4
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
5 use IMPL::Class::Property;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
6 use IMPL::Exception;
139
5a9f64890c31 Fixed module loading by the UriController
wizard
parents: 110
diff changeset
7 use Carp qw(croak);
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
8
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
9 BEGIN {
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
10 public property namespace => prop_all;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
11 }
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
12
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
13 __PACKAGE__->PassThroughArgs;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
14
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
15 sub Process {
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
16 my ($this,$action,$nextHandler) = @_;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
17
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
18 my $namespace = $this->namespace || $action->application->type;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
19
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
20 my @target = grep $_, split /\//, ($ENV{PATH_INFO} || '') or die new IMPL::Exception("No target specified");
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
21
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
22 my $method = pop @target;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
23 $method =~ s/\.\w+$//;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
24
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
25 my $module = join '::',$namespace,@target;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
26
139
5a9f64890c31 Fixed module loading by the UriController
wizard
parents: 110
diff changeset
27 eval "require $module; 1;" unless eval{ $module->can('InvokeAction'); };
5a9f64890c31 Fixed module loading by the UriController
wizard
parents: 110
diff changeset
28 if (my $err = $@ ) {
5a9f64890c31 Fixed module loading by the UriController
wizard
parents: 110
diff changeset
29 die new IMPL::Exception("Failed to load module",$module,$err);
5a9f64890c31 Fixed module loading by the UriController
wizard
parents: 110
diff changeset
30 }
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
31
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
32 if(UNIVERSAL::can($module,'InvokeAction')) {
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
33 $module->InvokeAction($method,$action);
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
34 } else {
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
35 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method);
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
36 }
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
37 }
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
38
110
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
39 1;
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
40
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
41 __END__
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
42
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
43 =pod
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
44
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
45 =head1 NAME
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
46
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
47 C<IMPL::Web::QueryHandler::UrlController> - вызов метода на основе <url> запроса.
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
48
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
49 =head1 DESCRIPTION
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
50
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
51 Использует переменную C<$ENV{PATH_INFO}> для получения имени и метода модуля.
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
52
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
53 =cut