This code works well:

           elif field.type == 'upload':
                f = self.vars[fieldname]
                fd = fieldname + '__delete'
                if f == '':
                    if self.vars.get(fd, False) or not self.record:
                        fields[fieldname] = ''
                    else:
                        fields[fieldname] = self.record[fieldname]
                    continue
                elif not isinstance(f, (str, unicode)):
                    (source_file, original_filename) = (f.file,
f.filename)
                else:
                    ### do not know why this happens, it should not
                    (source_file, original_filename) = \
                        (cStringIO.StringIO(f), 'file.txt')
                logging.warn('here')
                fields[fieldname] = field.store(source_file,
original_filename)
                logging.warn('there')
                if field.uploadfield and not field.uploadfield==True:
                    fields[field.uploadfield] = source_file.read()
                continue
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to