Patch proposed? to gluon/main.py - multiple file upload

22 views
Skip to first unread message

Maciek Sykulski

unread,
Oct 2, 2009, 6:06:57 AM10/2/09
to web2py-users
Hi Everyone, Hi Massimo,

I was having fun time working with web2py and setting up multiple file
upload in one form using
jquery.MultiFile.js from http://www.fyneworks.com/jquery/multiple-file-upload/
when I encountered the following problem:

When multiple files are uploaded in one form, they are send as a list
of files.
Such a list is captured properly by CherryPy, then,
web2py loses information about these files while parsing variables to
request.vars,
because it parses all lists trying to access its elements' .value
field.

I wasn't able to make it work properly until applying the following
patch to gluon/main.py:

diff -u --exclude='*pyc' web2py/gluon/main.py gluon/main.py
--- web2py/gluon/main.py 2009-08-17 15:21:17.000000000 +0200
+++ gluon/main.py 2009-08-21 17:09:58.000000000 +0200
@@ -346,7 +346,11 @@
for key in keys:
dpk = dpost[key]
if isinstance(dpk, list):
- value = [x.value for x in dpk]
+ #import pdb;pdb.set_trace()
+ if not dpk[0].filename:
+ value = [x.value for x in dpk]
+ else:
+ value = [x for x in dpk]
elif not dpk.filename:
value = dpk.value
else:

Should this patch be applied to the main tree, or maybe I'm missing
some other problems here?

Thanks!
Maciek Sykulski

PS: If someone's interested I've coded classes:
class MultiSQLFORM(SQLFORM):
class MultiCrud(Crud):
ready to use with jquery.MultiFile.js that handle uploading multiple
files to a database in a single form submission.

mdipierro

unread,
Oct 2, 2009, 9:22:55 AM10/2/09
to web2py-users
Thank you. Could you email it to me?

On Oct 2, 5:06 am, Maciek Sykulski <macie...@gmail.com> wrote:
> Hi Everyone, Hi Massimo,
>
> I was having fun time working with web2py and setting up multiple file
> upload in one form using
>     jquery.MultiFile.js  fromhttp://www.fyneworks.com/jquery/multiple-file-upload/

Maciek Sykulski

unread,
Oct 2, 2009, 11:20:49 AM10/2/09
to web2py-users
I emailed the patch and also the modified MultiSQLFORM class.

Wes James

unread,
Dec 17, 2009, 6:28:06 PM12/17/09
to web...@googlegroups.com
Maciek,

How is this working for you? Can I get a copy of your classes?

thx,

-wes

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups "web2py-users" group.
> To post to this group, send email to web...@googlegroups.com
> To unsubscribe from this group, send email to web2py+un...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/web2py?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>

Wes James

unread,
Dec 17, 2009, 6:40:38 PM12/17/09
to web...@googlegroups.com
Is the MultiSQLFORM in web2py? or MultiCRUD? Does anyone have an
example app that shows the multi file upload used here?

find . -name "*.py" -exec grep MultiSQLFORM {} \; -print

showed nothing in gluon....

thx,

-wes

Wes James

unread,
Dec 17, 2009, 11:26:47 PM12/17/09
to web...@googlegroups.com
Maciek,

Would you be able to add a slice on this here:

http://www.web2pyslices.com

thx,

-wes

Reply all
Reply to author
Forward
0 new messages