Mercurial > pub > Impl
annotate Lib/IMPL/Web/Application/Action.pm @ 229:47f77e6409f7
heavily reworked the resource model of the web application:
*some ResourcesContraact functionality moved to Resource
+Added CustomResource
*Corrected action handlers
| author | sergey |
|---|---|
| date | Sat, 29 Sep 2012 02:34:47 +0400 |
| parents | c8fe3f84feba |
| children | 6d8092d8ce1b |
| rev | line source |
|---|---|
| 52 | 1 package IMPL::Web::Application::Action; |
| 55 | 2 use strict; |
| 52 | 3 |
| 166 | 4 use parent qw(IMPL::Object IMPL::Object::Autofill); |
| 52 | 5 |
|
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
6 __PACKAGE__->PassThroughArgs; |
|
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
7 |
| 52 | 8 use IMPL::Class::Property; |
| 206 | 9 use Carp qw(carp); |
| 52 | 10 |
| 11 BEGIN { | |
| 194 | 12 public property application => prop_get | owner_set; |
| 13 public property query => prop_get | owner_set; | |
| 14 private property _entryPoint => prop_all; | |
| 55 | 15 } |
| 16 | |
| 65 | 17 sub CTOR { |
| 194 | 18 my ($this) = @_; |
| 19 | |
| 20 $this->context({}); | |
| 65 | 21 } |
|
63
76b878ad6596
Added serialization support for the IMPL::Object::List
wizard
parents:
62
diff
changeset
|
22 |
| 55 | 23 sub Invoke { |
| 194 | 24 my ($this) = @_; |
| 25 | |
| 26 if ($this->_entryPoint) { | |
| 27 $this->_entryPoint->(); | |
| 28 } else { | |
| 29 die new IMPL::InvalidOperationException("At least one handler is required"); | |
| 30 } | |
| 55 | 31 } |
| 32 | |
|
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
33 sub cookie { |
| 194 | 34 my ($this,$name,$rx) = @_; |
| 35 | |
| 36 $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
|
37 } |
|
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
38 |
|
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
39 sub param { |
| 194 | 40 my ($this,$name,$rx) = @_; |
| 41 | |
| 42 $this->_launder(scalar( $this->query->param($name) ), $rx ); | |
|
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
43 } |
|
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
44 |
|
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
45 sub requestMethod { |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
46 my ($this) = @_; |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
47 return $this->query->request_method; |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
48 } |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
49 |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
50 sub pathInfo { |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
51 my ($this) = @_; |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
52 return $this->query->path_info; |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
53 } |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
54 |
|
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
55 sub _launder { |
| 194 | 56 my ($this,$value,$rx) = @_; |
| 57 | |
| 58 if ( $value ) { | |
| 59 if ($rx) { | |
| 60 if ( my @result = ($value =~ m/$rx/) ) { | |
| 61 return @result > 1 ? \@result : $result[0]; | |
| 62 } else { | |
|
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
63 return; |
| 194 | 64 } |
| 65 } else { | |
| 66 return $value; | |
| 67 } | |
| 68 } else { | |
|
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
69 return; |
| 194 | 70 } |
|
144
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
71 } |
|
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
wizard
parents:
67
diff
changeset
|
72 |
| 52 | 73 1; |
| 74 | |
| 75 __END__ | |
| 76 | |
| 77 =pod | |
| 78 | |
| 67 | 79 =head1 NAME |
| 80 | |
| 180 | 81 C<IMPL::Web::Application::Action> - Обертка вокруг C<CGI> запроса. |
| 67 | 82 |
| 52 | 83 =head1 DESCRIPTION |
| 84 | |
| 67 | 85 C<[Infrastructure]> |
| 206 | 86 Свзяывет CGI запрос, приложение, орабатывающее его и ответ, который будет отправлен клиенту. |
| 52 | 87 |
| 67 | 88 =head1 MEMBERS |
| 89 | |
|
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
90 =head2 C<CTOR(%args)> |
| 67 | 91 |
|
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
92 Инициализирует новый экземпляр. Именованными параметрами передаются значения |
|
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
93 свойств. |
| 67 | 94 |
|
229
47f77e6409f7
heavily reworked the resource model of the web application:
sergey
parents:
206
diff
changeset
|
95 =head2 C< [get]application> |
| 67 | 96 |
| 180 | 97 Экземпляр приложения создавшего текущий объект |
| 67 | 98 |
| 99 =item C< [get] query > | |
| 100 | |
| 180 | 101 Экземпляр C<CGI> запроса |
| 67 | 102 |
| 103 =back | |
| 104 | |
| 105 | |
| 180 | 106 =cut |
