Mercurial > pub > Impl
annotate Lib/IMPL/Web/Application/Action.pm @ 249:0057f48f7945
fixed simple auth package to work with utf8 strings
author | sergey |
---|---|
date | Tue, 06 Nov 2012 20:00:57 +0400 |
parents | 7c517134c42f |
children | 32aceba4ee6d |
rev | line source |
---|---|
52 | 1 package IMPL::Web::Application::Action; |
55 | 2 use strict; |
52 | 3 |
206 | 4 use Carp qw(carp); |
52 | 5 |
238 | 6 use IMPL::Const qw(:prop); |
7 | |
8 use IMPL::declare { | |
9 base => [ | |
10 'IMPL::Object' => undef, | |
11 'IMPL::Object::Autofill' => '@_' | |
12 ], | |
13 props => [ | |
14 application => PROP_RO, | |
244 | 15 query => PROP_RO, |
16 context => PROP_RW | |
238 | 17 ] |
18 }; | |
55 | 19 |
65 | 20 sub CTOR { |
194 | 21 my ($this) = @_; |
244 | 22 |
23 $this->context({}); | |
65 | 24 } |
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
25 |
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
26 sub cookie { |
194 | 27 my ($this,$name,$rx) = @_; |
28 | |
29 $this->_launder(scalar( $this->query->cookie($name) ), $rx ); | |
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
30 } |
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
31 |
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
32 sub param { |
194 | 33 my ($this,$name,$rx) = @_; |
34 | |
245 | 35 my $value; |
36 | |
37 if ( | |
38 $this->requestMethod eq 'GET' | |
39 or | |
40 $this->query->content_type eq 'multipart/form-data' | |
41 or | |
42 $this->query->content_type eq 'application/x-www-form-urlencoded' | |
43 ) { | |
44 $value = scalar( $this->query->param($name) ); | |
45 } else { | |
46 $value = scalar( $this->query->url_param($name) ); | |
47 } | |
48 | |
49 $this->_launder($value, $rx ); | |
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
50 } |
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
51 |
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
52 sub requestMethod { |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
53 my ($this) = @_; |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
54 return $this->query->request_method; |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
55 } |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
56 |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
57 sub pathInfo { |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
58 my ($this) = @_; |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
59 return $this->query->path_info; |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
60 } |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
61 |
238 | 62 sub baseUrl { |
63 my ($this) = @_; | |
64 | |
65 return $this->query->url(-base => 1); | |
66 } | |
67 | |
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
68 sub _launder { |
194 | 69 my ($this,$value,$rx) = @_; |
70 | |
71 if ( $value ) { | |
72 if ($rx) { | |
73 if ( my @result = ($value =~ m/$rx/) ) { | |
74 return @result > 1 ? \@result : $result[0]; | |
75 } else { | |
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
76 return; |
194 | 77 } |
78 } else { | |
79 return $value; | |
80 } | |
81 } else { | |
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
82 return; |
194 | 83 } |
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
84 } |
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
85 |
52 | 86 1; |
87 | |
88 __END__ | |
89 | |
90 =pod | |
91 | |
67 | 92 =head1 NAME |
93 | |
180 | 94 C<IMPL::Web::Application::Action> - Обертка вокруг C<CGI> запроса. |
67 | 95 |
52 | 96 =head1 DESCRIPTION |
97 | |
67 | 98 C<[Infrastructure]> |
206 | 99 Свзяывет CGI запрос, приложение, орабатывающее его и ответ, который будет отправлен клиенту. |
52 | 100 |
67 | 101 =head1 MEMBERS |
102 | |
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
103 =head2 C<CTOR(%args)> |
67 | 104 |
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
105 Инициализирует новый экземпляр. Именованными параметрами передаются значения |
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
106 свойств. |
67 | 107 |
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
108 =head2 C< [get]application> |
67 | 109 |
180 | 110 Экземпляр приложения создавшего текущий объект |
67 | 111 |
112 =item C< [get] query > | |
113 | |
180 | 114 Экземпляр C<CGI> запроса |
67 | 115 |
116 =back | |
117 | |
118 | |
180 | 119 =cut |