[Html-widget] uploads in the results object?

John Napiorkowski jjn1056 at yahoo.com
Tue Nov 14 15:34:43 GMT 2006


--- 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.

I'm also using catalyst for this, the way I preset my
form object is like:

if( $c->request->param($self->form_id) )
{
  $self->form->query($c->request);
  $self->form->uploads($c->request->uploads);	

  $self->submitted(1);
}
else
{
  $self->form->query(undef);
  $self->form->uploads(undef);		
}

Which is code I pretty much lifted from one
Catalyst::Plugin::HTMLWidget (I think) so that the
form object is all set to go.  I have this application
where people upload media files and I use Imager.pm to
resize it and convert to jpeg (Imager.pm is way cool
by the way, a lot easer to use the GD or Imagemajick).
 Right now I have this working with a lot of hackery
in my common form to database code.

The way I see that it works is that
$results->param('upload_field') returns the file name
uploaded, which I then have to go look up in the
$form->uploads to get the filehandle.

Ideally I would like to implement my 'resize and
convert' as a filter on the upload field, that way I
can keep all that logic in the form area and out of my
controller.

So what I'm wonder is:

1) Do we think that adding a $results->uploads which
has everything from the form->uploads but processed
via the constraints and filters? 

Or 2) Would we prefer that instead of
$results->param('upload') return the file name that it
return the upload object but stringify to the old
behavior for compatibility?

To be honest I lean toward something more like #2
because that would be easier for my common code :)

Another issue is that $upload_widget doesn't seem to
have a 'value' method.  At least we I do:

$upload_widget->can('value')

That fails.  I would prefer it succeed.  What about
the rest of you?

I'd like to work on this but to be honest I need a few
hints to get started.  Should I just checkout from SVN
and offer patches?

Thanks!

_john


> 
> Carl
> 
> _______________________________________________
> Html-widget mailing list
> Html-widget at lists.rawmode.org
>
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget
> 



 
____________________________________________________________________________________
Cheap talk?
Check out Yahoo! Messenger's low PC-to-Phone call rates.
http://voice.yahoo.com



More information about the Html-widget mailing list