# HG changeset patch # User wizard # Date 1277943907 -14400 # Node ID c5bc900eefd3aafe868642c76975774bd0044dd6 # Parent 6975cd4973d1dea0c3299bff32e93b5942911136 IMPL::Web::Application: Fixed file uploading Minor improvements in the IMPL::Web::TT::Form diff -r 6975cd4973d1 -r c5bc900eefd3 Lib/IMPL/Web/Application.pm --- a/Lib/IMPL/Web/Application.pm Tue Jun 29 00:37:05 2010 +0400 +++ b/Lib/IMPL/Web/Application.pm Thu Jul 01 04:25:07 2010 +0400 @@ -99,9 +99,13 @@ use Encode; +our $NO_DECODE = 0; + sub param { my $this = shift; + return $this->SUPER::param(@_) if $NO_DECODE; + if (wantarray) { my @result = $this->SUPER::param(@_); @@ -114,6 +118,19 @@ } +sub upload { + my $this = shift; + + local $NO_DECODE = 1; + my $oldCharset = $this->charset(); + $this->charset('ISO-8859-1'); + + my $fh = $this->SUPER::upload(@_); + + $this->charset($oldCharset); + return $fh; +} + 1; __END__ diff -r 6975cd4973d1 -r c5bc900eefd3 Lib/IMPL/Web/Application/ControllerUnit.pm --- a/Lib/IMPL/Web/Application/ControllerUnit.pm Tue Jun 29 00:37:05 2010 +0400 +++ b/Lib/IMPL/Web/Application/ControllerUnit.pm Thu Jul 01 04:25:07 2010 +0400 @@ -140,6 +140,7 @@ $form ); + $result{formName} = $form; $result{formSchema} = $schema; $result{formData} = $transform->Transform($action->query); diff -r 6975cd4973d1 -r c5bc900eefd3 Lib/IMPL/Web/TT/Form.pm --- a/Lib/IMPL/Web/TT/Form.pm Tue Jun 29 00:37:05 2010 +0400 +++ b/Lib/IMPL/Web/TT/Form.pm Thu Jul 01 04:25:07 2010 +0400 @@ -5,8 +5,6 @@ use IMPL::Class::Property; use IMPL::DOM::Navigator::SchemaNavigator; -use IMPL::DOM::Property qw(_dom); - __PACKAGE__->PassThroughArgs; BEGIN { @@ -14,19 +12,30 @@ public property schema => prop_all; public property errors => prop_all; public property data => prop_all; + public property state => prop_all; + public property formResult => prop_all; } sub CTOR { my ($this) = @_; - $this->base($this->nodeName) unless $this->base; + if (my $form = $this->formResult) { + $this->base($form->{formName}); + $this->errors($form->{formErrors}); + $this->data($form->{formData}); + $this->schema($form->{formSchema}); + $this->state($form->{state}); + } else { - die new IMPL::InvalidArgumentException('A schema is required for a form',$this->nodeName) - unless eval { $this->schema->isa( typeof IMPL::DOM::Schema ) }; - - die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base) - unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base }); + $this->base($this->nodeName) unless $this->base; + + die new IMPL::InvalidArgumentException('A schema is required for a form',$this->nodeName) + unless eval { $this->schema->isa( typeof IMPL::DOM::Schema ) }; + die new IMPL::InvalidOperationException('Can\'t find a form definition in a schema',$this->nodeName,$this->base) + unless $this->schema->selectNodes(sub { $_->nodeName eq 'ComplexNode' and $_->name eq $this->base }); + } + $this->errors([]) unless $this->errors; } @@ -47,7 +56,7 @@ my $sourceSchema = $navi->SourceSchemaNode; my $queryParameter = join '/', @path; shift @path; - my $node = $this->data->selectSingleNode(@path); + my $node = $this->data ? $this->data->selectSingleNode(@path) : undef; my @errors;