Mercurial > pub > Impl
annotate Lib/IMPL/Web/Application/Action.pm @ 244:a02b110da931
refactoring
fixed binding to CGI query parameters with multiple values
| author | sergey | 
|---|---|
| date | Mon, 22 Oct 2012 04:09:27 +0400 | 
| parents | b8c724f6de36 | 
| children | 7c517134c42f | 
| 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: 
62diff
changeset | 25 | 
| 144 
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
 wizard parents: 
67diff
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: 
67diff
changeset | 30 } | 
| 
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
 wizard parents: 
67diff
changeset | 31 | 
| 
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
 wizard parents: 
67diff
changeset | 32 sub param { | 
| 194 | 33 my ($this,$name,$rx) = @_; | 
| 34 | |
| 35 $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: 
67diff
changeset | 36 } | 
| 
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
 wizard parents: 
67diff
changeset | 37 | 
| 229 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 38 sub requestMethod { | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 39 my ($this) = @_; | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 40 return $this->query->request_method; | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 41 } | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 42 | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 43 sub pathInfo { | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 44 my ($this) = @_; | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 45 return $this->query->path_info; | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 46 } | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 47 | 
| 238 | 48 sub baseUrl { | 
| 49 my ($this) = @_; | |
| 50 | |
| 51 return $this->query->url(-base => 1); | |
| 52 } | |
| 53 | |
| 144 
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
 wizard parents: 
67diff
changeset | 54 sub _launder { | 
| 194 | 55 my ($this,$value,$rx) = @_; | 
| 56 | |
| 57 if ( $value ) { | |
| 58 if ($rx) { | |
| 59 if ( my @result = ($value =~ m/$rx/) ) { | |
| 60 return @result > 1 ? \@result : $result[0]; | |
| 61 } else { | |
| 229 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 62 return; | 
| 194 | 63 } | 
| 64 } else { | |
| 65 return $value; | |
| 66 } | |
| 67 } else { | |
| 229 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 68 return; | 
| 194 | 69 } | 
| 144 
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
 wizard parents: 
67diff
changeset | 70 } | 
| 
b56ebc31bf18
Empty nodes no more created while transforming a post request to the DOM document
 wizard parents: 
67diff
changeset | 71 | 
| 52 | 72 1; | 
| 73 | |
| 74 __END__ | |
| 75 | |
| 76 =pod | |
| 77 | |
| 67 | 78 =head1 NAME | 
| 79 | |
| 180 | 80 C<IMPL::Web::Application::Action> - Обертка вокруг C<CGI> запроса. | 
| 67 | 81 | 
| 52 | 82 =head1 DESCRIPTION | 
| 83 | |
| 67 | 84 C<[Infrastructure]> | 
| 206 | 85 Свзяывет CGI запрос, приложение, орабатывающее его и ответ, который будет отправлен клиенту. | 
| 52 | 86 | 
| 67 | 87 =head1 MEMBERS | 
| 88 | |
| 229 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 89 =head2 C<CTOR(%args)> | 
| 67 | 90 | 
| 229 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 91 Инициализирует новый экземпляр. Именованными параметрами передаются значения | 
| 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 92 свойств. | 
| 67 | 93 | 
| 229 
47f77e6409f7
heavily reworked the resource model of the web application:
 sergey parents: 
206diff
changeset | 94 =head2 C< [get]application> | 
| 67 | 95 | 
| 180 | 96 Экземпляр приложения создавшего текущий объект | 
| 67 | 97 | 
| 98 =item C< [get] query > | |
| 99 | |
| 180 | 100 Экземпляр C<CGI> запроса | 
| 67 | 101 | 
| 102 =back | |
| 103 | |
| 104 | |
| 180 | 105 =cut | 
