Re: [Webware-devel] Changing HTTPRequest.py to allow multiple file uploads.

2015-06-08 Thread Gary Perez
Hi, Christoph.

I just tested it, and it seems to work perfectly.

Thanks!
-Gary



> On Jun 7, 2015, at 5:13, Christoph Zwerschke  wrote:
> 
> Am 28.05.2015 um 18:10 schrieb Gary Perez:
>> I'm not in a rush, so whenever you are done with vacation, here are
>> the relevant parts (complete with inane comments):
> 
> Thanks, I simplified the code and committed the change to the trunk:
> 
> http://svn.w4py.org/Webware/trunk/WebKit/HTTPRequest.py
> 
> Let me know if this works for you.
> 
> -- Christoph
> 
> --
> ___
> Webware-devel mailing list
> Webware-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/webware-devel


--
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel


Re: [Webware-devel] Changing HTTPRequest.py to allow multiple file uploads.

2015-06-07 Thread Christoph Zwerschke
Am 28.05.2015 um 18:10 schrieb Gary Perez:
> I'm not in a rush, so whenever you are done with vacation, here are
> the relevant parts (complete with inane comments):

Thanks, I simplified the code and committed the change to the trunk:

http://svn.w4py.org/Webware/trunk/WebKit/HTTPRequest.py

Let me know if this works for you.

-- Christoph

--
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel


Re: [Webware-devel] Changing HTTPRequest.py to allow multiple file uploads.

2015-06-06 Thread Gary Perez
Hi, Christoph.

I'm not in a rush, so whenever you are done with vacation, here are the 
relevant parts (complete with inane comments):

# Webware 1.1.1, HTTPRequest.py, Lines 118-133  ##

if fieldItems:
for value in fieldItems:
fields.setdefault(value.name, []).append(value)
getValue = attrgetter('value')
for key, value in fields.iteritems():
if len(value) > 1:
value = map(getValue, value)
else:
value = value[0]
if value.filename:
if debug:
print "Uploaded file found:", value.filename
else:
value = value.value
fields[key] = value
self._fieldStorage, self._fields = fieldStorage, fields

# My proposed changes, starting Line 118  ##

if fieldItems:
for value in fieldItems:
fields.setdefault(value.name, []).append(value)
getValue = attrgetter('value')

for key, value in fields.iteritems():
# IMPORTANT! value here is *always* a list, but it may contain 
only 1 member.
# Are there multiple values for same key in the form?
# This could be series of date pulldowns, or multiple file 
uploads.
if len(value) > 1:
# Analyze members of this list, set flag as appropriate
IS_UPLOADS = False
for listitem in value:
try:
if listitem.filename: # True for an uploaded file
IS_UPLOADS = True
except AttributeError: # [str].filename throws this
pass

# Check flag
if IS_UPLOADS:
# The existing list of FieldStorage objects is exactly 
what we want, so we alter nothing here.
pass
else:
# Append the regular strings to the key's list.
value = map(getValue, value)

else: # Only one value for this key
value = value[0]
# Now, is this an upload?
try:
if value.filename:
if debug:
print "Uploaded file found:", value.filename
else:
value = value.value
except AttributeError: # [str].filename throws this
value = value.value

fields[key] = value
self._fieldStorage, self._fields = fieldStorage, fields




Enjoy your holiday! Thanks,
-Gary


> On May 28, 2015, at 11:56, Christoph Zwerschke  wrote:
> 
> Hi Gary,
> 
> thanks for the suggestion. I'm still maintaining Webware and will look 
> into any suggestion made here, though it may take some time (currently 
> on vacation).
> 
> You can also post patches and requests to
> http://sourceforge.net/p/webware/feature-requests/
> 
> -- Christoph
> 
> --
> ___
> Webware-devel mailing list
> Webware-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/webware-devel


--
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel


Re: [Webware-devel] Changing HTTPRequest.py to allow multiple file uploads.

2015-05-28 Thread Christoph Zwerschke
Hi Gary,

thanks for the suggestion. I'm still maintaining Webware and will look 
into any suggestion made here, though it may take some time (currently 
on vacation).

You can also post patches and requests to
http://sourceforge.net/p/webware/feature-requests/

-- Christoph

--
___
Webware-devel mailing list
Webware-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/webware-devel