In gluon/sqlhtml.py there is this logic:

 elif field.type == 'upload':
                f = self.vars[fieldname]
                fd = '%s__delete' % fieldname
                ...
                newfilename = field.store(source_file, original_filename,
                                          field.uploadfolder)

can you add some print statements and help us debug. How it is possible 
that source_file is None? What is the value of the variable f when this 
happens.

it should accept any character in the original filename. If it does not, 
where does it fail? 

Please open a ticket and link this thread so the issue gets tracked.


On Tuesday, 24 July 2012 02:51:50 UTC-5, Annet wrote:
>
> In a table I defined the following field:
>
> Field('photoFile',type='upload',autodelete=True),
>
> with the following validator:
>
> db.Person.photoFile.requires=IS_EMPTY_OR(IS_IMAGE(extensions=('gif','jpg','jpeg','png'),maxsize=(72,72)),IS_LENGTH(36*1024,error_message='file
>  
> size exceeds 36 KB'))
>
> When I insert a person without a photoFile I get the following error:
>
>
> Traceback (most recent call last):
>   File "/Library/Python/2.5/site-packages/web2py/gluon/restricted.py", line 
> 205, in restricted
>     exec ccode in environment
>   File 
> "/Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/appadmin.py"
>  
> <http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/appadmin.py>, 
> line 433, in <module>
>   File "/Library/Python/2.5/site-packages/web2py/gluon/globals.py", line 173, 
> in <lambda>
>     self._caller = lambda f: f()
>   File 
> "/Library/Python/2.5/site-packages/web2py/applications/bootstrap/controllers/appadmin.py"
>  
> <http://127.0.0.1:8000/admin/default/edit/bootstrap/controllers/appadmin.py>, 
> line 128, in insert
>     if form.accepts(request.vars, session):
>   File "/Library/Python/2.5/site-packages/web2py/gluon/sqlhtml.py", line 
> 1207, in accepts
>     newfilename = field.store(source_file, original_filename, 
> field.uploadfolder)
> UnboundLocalError: local variable 'source_file' referenced before assignment
>
>
> This is in web2py version 1.99.7
>
> Kind regards,
>
> Annet
>
>
>

-- 



Reply via email to