Mercurial > pub > Impl
changeset 171:59e5fcb59d86
Исправления, изменена концепция веб-форм
author | sourcer |
---|---|
date | Mon, 06 Jun 2011 03:30:36 +0400 |
parents | b88b7fe60aa3 |
children | 068acfe903c3 |
files | Lib/IMPL/Class/Meta.pm Lib/IMPL/Object/Clonable.pm Lib/IMPL/Web/Application/ControllerUnit.pm Lib/IMPL/Web/QueryHandler/PageFormat.pm Lib/IMPL/Web/TT/Control.pm Lib/IMPL/Web/TT/Document.pm |
diffstat | 6 files changed, 24 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/Lib/IMPL/Class/Meta.pm Tue May 24 01:11:16 2011 +0400 +++ b/Lib/IMPL/Class/Meta.pm Mon Jun 06 03:30:36 2011 +0400 @@ -1,7 +1,7 @@ package IMPL::Class::Meta; use strict; -use Storable qw(dclone); +use Clone qw(clone); my %class_meta; my %class_data; @@ -49,7 +49,7 @@ $class_data{$class}{$name}; } else { if ( my $value = $class->_find_class_data($name) ) { - $class_data{$class}{$name} = dclone($value); + $class_data{$class}{$name} = clone($value); } else { undef; }
--- a/Lib/IMPL/Object/Clonable.pm Tue May 24 01:11:16 2011 +0400 +++ b/Lib/IMPL/Object/Clonable.pm Mon Jun 06 03:30:36 2011 +0400 @@ -1,10 +1,10 @@ package IMPL::Object::Clonable; use strict; -use Storable qw(dclone); +use Clone qw(clone); sub Clone { - dclone($_[0]); + clone($_[0]); } 1; \ No newline at end of file
--- a/Lib/IMPL/Web/Application/ControllerUnit.pm Tue May 24 01:11:16 2011 +0400 +++ b/Lib/IMPL/Web/Application/ControllerUnit.pm Mon Jun 06 03:30:36 2011 +0400 @@ -72,8 +72,6 @@ schema => $info }; } elsif (ref $info eq 'HASH') { - die new IMPL::Exception("A schema must be specified",$self,$method) unless $info->{schema}; - $info->{wrapper} = 'FormWrapper'; $self->class_data(CONTROLLER_METHODS)->{$method} = $info; @@ -137,13 +135,12 @@ sub FormWrapper { my ($self,$method,$action,$methodInfo) = @_; - my $schema = $self->loadSchema($methodInfo->{schema}); + my $schema = $methodInfo->{schema} ? $self->loadSchema($methodInfo->{schema}) : $self->unitSchema; my $process = $action->query->param('process') || 0; my $form = $methodInfo->{form} || $action->query->param('form') - || $schema->selectSingleNode('ComplexNode')->name - or die new IMPL::Exception('No situable form name could be determined',$self,$method); + || $method; my %result; @@ -155,10 +152,9 @@ $result{formName} = $form; $result{formSchema} = $schema; - $result{formData} = $transform->Transform($action->query); - if ($process) { + $result{formData} = $transform->Transform($action->query); $result{formErrors} = $transform->Errors->as_list; if ($transform->Errors->Count) { $result{state} = STATE_INVALID; @@ -179,6 +175,14 @@ } } } else { + if (my $initMethod = $methodInfo->{init}) { + my $unit = $self->new($action,\%result); + $result{formData} = $transform->Transform( $unit->$initMethod($unit->MakeParams($methodInfo)) ); + } else { + $result{formData} = $transform->Transform($action->query); + } + + $result{formErrors} = $transform->Errors->as_list; $result{state} = STATE_NEW; }
--- a/Lib/IMPL/Web/QueryHandler/PageFormat.pm Tue May 24 01:11:16 2011 +0400 +++ b/Lib/IMPL/Web/QueryHandler/PageFormat.pm Mon Jun 06 03:30:36 2011 +0400 @@ -8,11 +8,12 @@ use IMPL::Class::Property; use IMPL::Web::TT::Document; use Template::Plugin::URL; -use IMPL::Security::Context; -use File::Spec; -use HTML::TreeBuilder; -use URI; +use IMPL::Security::Context(); +use File::Spec(); +use HTML::TreeBuilder(); +use URI(); use Error qw(:try); +use Encode(); $Template::Plugin::URL::JOINT = '&'; @@ -44,7 +45,7 @@ $this->templatesBase($ENV{DOCUMENT_ROOT}) unless $this->templatesBase; - my ($requestUri) = split /\?/, $ENV{REQUEST_URI}; + my ($requestUri) = split( /\?/, $ENV{REQUEST_URI} ); my $pathInfo; my @root = (''); @@ -125,7 +126,7 @@ my $clone = $this->clone; if (ref $params eq 'HASH' ) { my %newParams = ($clone->query_form , %$params); - $clone->query_form(map { $_, $newParams{$_} } sort keys %newParams ); + $clone->query_form(map { $_, ( Encode::is_utf8( $newParams{$_} ) ? Encode::encode('utf-8', $newParams{$_}) : $newParams{$_} ) } sort keys %newParams ); } return $clone; }
--- a/Lib/IMPL/Web/TT/Control.pm Tue May 24 01:11:16 2011 +0400 +++ b/Lib/IMPL/Web/TT/Control.pm Mon Jun 06 03:30:36 2011 +0400 @@ -2,6 +2,7 @@ use parent qw(IMPL::Web::TT::Collection); + use IMPL::Class::Property; use IMPL::DOM::Property qw(_dom); @@ -41,5 +42,4 @@ } } } - 1; \ No newline at end of file
--- a/Lib/IMPL/Web/TT/Document.pm Tue May 24 01:11:16 2011 +0400 +++ b/Lib/IMPL/Web/TT/Document.pm Mon Jun 06 03:30:36 2011 +0400 @@ -266,7 +266,7 @@ my @result = $this->selectNodes($method); return $result[0] if @result; - carp "Looks like you have a mistake, document doesn't have a such property or child: $method"; + carp "Looks like you have a mistake, the document doesn't have a such property or child: $method"; return; }