annotate Lib/IMPL/Web/QueryHandler/UrlController.pm @ 117:0475eb382085

Controls support (RC1)
author wizard
date Thu, 03 Jun 2010 02:41:44 +0400
parents c13a215508ca
children 5a9f64890c31
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;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
7 use Carp;
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
110
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
27 eval "require $module; 1;" unless $INC{$module};
97
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
28 carp $@ if $@;
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
29
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
30 if(UNIVERSAL::can($module,'InvokeAction')) {
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
31 $module->InvokeAction($method,$action);
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
32 } else {
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
33 die new IMPL::InvalidOperationException("Failed to invoke action",$ENV{PATH_INFO},$module,$method);
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
34 }
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
35 }
964587c5183c Added SecureCall to Web QueryHandlers stack
wizard
parents:
diff changeset
36
110
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
37 1;
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
38
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
39 __END__
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
40
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
41 =pod
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
42
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
43 =head1 NAME
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
44
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
45 C<IMPL::Web::QueryHandler::UrlController> - вызов метода на основе <url> запроса.
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
46
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
47 =head1 DESCRIPTION
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
48
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
49 Использует переменную C<$ENV{PATH_INFO}> для получения имени и метода модуля.
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
50
c13a215508ca Refactoring,
wizard
parents: 97
diff changeset
51 =cut