[Jifty-commit] jifty branch, plack, updated. d51fcb314b4059fc74cb64377b0ae09c69b16990

Jifty commits jifty-commit at lists.jifty.org
Mon Jan 11 22:39:04 EST 2010


The branch, plack has been updated
       via  d51fcb314b4059fc74cb64377b0ae09c69b16990 (commit)
      from  b6ffecc72d1976e0dfaa272d19cfeff32d60f4c3 (commit)

Summary of changes:
 lib/Jifty/Request.pm        |    9 +++++----
 lib/Jifty/Web/FileUpload.pm |   21 ++++++++++++++++++---
 2 files changed, 23 insertions(+), 7 deletions(-)

- Log -----------------------------------------------------------------
commit d51fcb314b4059fc74cb64377b0ae09c69b16990
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Tue Jan 12 11:17:45 2010 +0800

    handle uploads.

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index b6f36fa..9b1223f 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -283,12 +283,13 @@ sub from_args {
         } elsif(!ref($val)) {
             $args{$k} = Jifty::I18N->promote_encoding($val, $self->content_type);
         }
+    }
 
-        if (ref($val) eq 'Fh') {
-            $args{$k} = Jifty::Web::FileUpload->new_from_fh($val);
-        }
+    my $uploads = $self->uploads;
+    for my $k (keys %$uploads) {
+        my $val = $uploads->{$k};
+        $args{$k} = Jifty::Web::FileUpload->new_from_plack($val);
     }
-    
     my @splittable_names = grep /=|\|/, keys %args;
     for my $splittable (@splittable_names) {
         delete $args{$splittable};
diff --git a/lib/Jifty/Web/FileUpload.pm b/lib/Jifty/Web/FileUpload.pm
index ffd3676..5f24fba 100644
--- a/lib/Jifty/Web/FileUpload.pm
+++ b/lib/Jifty/Web/FileUpload.pm
@@ -66,9 +66,6 @@ sub new {
 
     my $fh = $args{filehandle};
 
-    ref($fh) eq 'Fh'
-        or die "The filehandle must be an Fh object produced by CGI";
-
     if (!defined($args{filename})) {
         $args{filename} = "$fh";
 
@@ -77,6 +74,9 @@ sub new {
     }
 
     if (!defined($args{content_type})) {
+        ref($fh) eq 'Fh'
+            or die "The filehandle must be an Fh object produced by CGI";
+
         my $info = Jifty->handler->cgi->uploadInfo($fh);
         $args{content_type} = $info->{'Content-Type'}
             if defined $info;
@@ -118,6 +118,7 @@ Convenience method, since the other bits can be gleaned from the L<Fh> object.
 
 =cut
 
+# DEPRECATED
 sub new_from_fh {
     my $self = shift;
     my $fh   = shift;
@@ -125,5 +126,19 @@ sub new_from_fh {
     $self->new(filehandle => $fh);
 }
 
+=head2 new_from_plack $u
+
+=cut
+
+sub new_from_plack {
+    my $self = shift;
+    my $u    = shift;
+
+    $self->new(filehandle   => $u->fh,
+               filename     => $u->filename,
+               content_type => $u->type,
+           );
+}
+
 1;
 

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list