On Thursday, January 16, 2014 12:29:11 PM UTC-5, LaDarrius Stewart wrote:
>
>
> from the form2 in the upload method above is how the link is made and the 
> custom store retrieve was from an example on the web there isnt many.
> But its like its not even using the custom retrieve cause why is looking 
> there for the file.
>

For upload fields, the grid constructs a default link, which simply appends 
/download/filename to the grid URL. When that URL is requested, the grid 
itself handles the download by calling response.download(). 
response.download() will call field.retrieve(), which will call your 
custom_retrieve method, but the problem is that response.download() expects 
the filename to start with tablename.fieldname, and your custom_store 
method does not do that, so the file is not found.

As an alternative, you can specify your own URL to handle the downloading 
via the "upload" argument to SQLFORM.grid. However, you're probably better 
off just using the built-in mechanism for uploads/downloads. The custom 
methods are for when you need to do something differently, but you largely 
appear to be replicating the built-in methods (though in a less secure way 
-- no file renaming or checks to prevent directory traversal attacks).
 

> Is there and example of using the built in way?
>

Just define a field as an "upload" field, and uploads are handled 
automatically and downloads are easily handled with response.download(). If 
using the grid, everything will just work.

Anthony

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to