[Html-widget] RFC Handling uploads, WAS uploads in the results object?

John Napiorkowski jjn1056 at yahoo.com
Tue Nov 14 18:17:16 GMT 2006


Hi,

Okay, sorry to post so many brain dumps about this
upload issue but now that I've spent some time looking
at the code for this and for the way uploads are
handled in Catalyst and CGI.pm I have some thoughts
and would really like to get some opinions.

First of all I don't think having the uploads method
or attribute should be an Apache::Uploads object. 
Right now there is nothing in the code enforcing that,
and although the upload reference is passed to
contraints, filters and elements, nothing is being
done with that so changing this won't break anything,
as far as I know.

The documentation specifics that:

my $w = HTML::Widget->new('widget');

$w->uploads($arrayref)

where the arrayref should be of Apache Upload objects.
 However my guess is that most people are using this
primarily in catalyst or for CGI development, and
between the three methods for accessing uploads
(Catalyst->request->uploads, Apache::Uploads and
CGI.pm) there are significant differences.

As far as I can see there are only two things to do,
either make a least common denominator structure to
pass to uploads or to create a new interface objects
that you'd need to build based on the upload interface
of your choice.

For solution one that structure would probably have to
a hashref something like:

{
  uploadfieldname1 => {
    
    fh => <filehandle>,
    size => xxxxd,
  },
  uploadfieldname2 => {
    
    fh => <filehandle>,
    size => xxxxd,
  },
}

Since there isn't much in common between the standard
ways I've found of accessing uploads.

For the second method, create an interface, we could
do it to be the 'most common denominator' method,
which would be a catalyst compatible hashref of
objects.  Then we'd have parse plugins to convert from
CGI.pm, Apache::Upload and Catalyst to that common
interface.

Then it wouldn't be so hard to make the filters and
constraints work.

What do you think?

--john


--- John Napiorkowski <jjn1056 at yahoo.com> wrote:

> Also, it appears that the catalyst upload object
> isn't
> 100% the same as the apache::upload object that
> html::widget needs...  The biggest missing thing the
> a
> 'name' field.  I think this is because in catalyst
> the
> upload method returns a hashref keyed by the field
> name, whereas apache upload wants the field name as
> an
> accessor in the upload object since it seems to
> return
> everything as an arrayref.
> 
> Seems like there is a lot to do here!
> 
> --john
> 
> --- John Napiorkowski <jjn1056 at yahoo.com> wrote:
> 
> > 
> > --- Carl Franks <fireartist at gmail.com> wrote:
> > 
> > > On 14/11/06, Bogdan Lucaciu <bogdan at wiz.ro>
> wrote:
> > > > On Tuesday 14 November 2006 11:12, Carl Franks
> > > wrote:
> > > > > Looks like you're the first person to try
> > using
> > > H-W for file uploads!
> > > > > That's rather amusing.
> > > >
> > > > I use Catalyst::Request::Upload :)
> > > 
> > > I think I must have done the same without
> thinking
> > > about it.
> > > Though, because $w->uploads() is compatible with
> > > $request->uploads, it
> > > would make sense to use H-W in conjunction with
> > it's
> > > constraints. The
> > > All constraint would be suitable. We could also
> > add
> > > some
> > > upload-specific constraints to check filesize,
> > > mimetype, ...
> > > I think we'll need to go through all the
> > > constraints, change suitable
> > > ones to also check file uploads - and document
> > which
> > > ones work.
> > > 
> > > Carl
> > 
> > I'm not completely I understand the expected way
> to
> > pass uploads...  According to the catalyst manual,
> > $c->request->uploads returns a hashref, while the
> > uploads method seems to want an arrayref.  Am I
> > right
> > in thinking that the way process an html widget
> > object
> > with uploads from catalyst should be:
> > 
> > my @uploads = map values %{$c->request->uploads};
> > $form->process( $c->request, [@uploads]);
> > 
> > Anybody make this work?
> > 
> > --john
> > 
> > 
> > 
> > > 
> > > _______________________________________________
> > > Html-widget mailing list
> > > Html-widget at lists.rawmode.org
> > >
> >
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
> > > 
> > 
> > 
> > 
> >  
> >
>
____________________________________________________________________________________
> > Do you Yahoo!?
> > Everyone is raving about the all-new Yahoo! Mail
> > beta.
> > http://new.mail.yahoo.com
> > 
> > _______________________________________________
> > Html-widget mailing list
> > Html-widget at lists.rawmode.org
> >
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
> > 
> 
> 
> 
>  
>
____________________________________________________________________________________
> Do you Yahoo!?
> Everyone is raving about the all-new Yahoo! Mail
> beta.
> http://new.mail.yahoo.com
> 
> _______________________________________________
> Html-widget mailing list
> Html-widget at lists.rawmode.org
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
> 



 
____________________________________________________________________________________
Do you Yahoo!?
Everyone is raving about the all-new Yahoo! Mail beta.
http://new.mail.yahoo.com



More information about the Html-widget mailing list