possible fix for issue 188, thanks Marin

This commit is contained in:
mdipierro
2012-07-30 16:25:35 -05:00
parent e912f1084c
commit bac7e433c6
2 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-07-29 21:55:47) dev
Version 2.00.0 (2012-07-30 16:25:32) dev
+3 -3
View File
@@ -1229,6 +1229,7 @@ class SQLFORM(FORM):
continue # do not update if password was not changed
elif field.type == 'upload':
f = self.vars[fieldname]
f = f or self.table[fieldname].default or f
fd = '%s__delete' % fieldname
if f == '' or f is None:
if self.vars.get(fd, False) or not self.record:
@@ -1240,9 +1241,8 @@ class SQLFORM(FORM):
elif hasattr(f, 'file'):
(source_file, original_filename) = (f.file, f.filename)
elif isinstance(f, (str, unicode)):
### do not know why this happens, it should not
(source_file, original_filename) = \
(cStringIO.StringIO(f), 'file.txt')
# warning: possible IOError exception
(source_file, original_filename) = (open(f, 'rb'), f)
newfilename = field.store(source_file, original_filename,
field.uploadfolder)
# this line is for backward compatibility only