>
> Another alternative is to change the representation of the file field in 
> the controller function before creating the SQLFORM.grid. For example:
>
> db.datasets.file.represent = lambda value, row: A('Download file', _href=
> URL('datasets', 'download_dataset', vars={'id': row.id}))
>
> I thought that would derail the upload widget in the SQLFORM edit view but 
> it doesn't seem to. Its probably a simpler way to get a custom download 
> link that points to the record rather than just the filename, but doesn't 
> get around the need for a custom download function.
>

Yes, that would be a simple alternative. But you don't need to customize 
the download function in that case -- instead, you could simply set the 
uploadfolder of the field based on the incoming URL, either in a model 
file, or in the download function. Let's say you want to use the standard 
download function and you structure the download URLs like 
/default/download/[filename]?dataset_id=[some_id]. Then you can do 
something like:

if 'dataset_id' in request.vars:
    db.datasets.file.uploadfolder = os.path.join(request.folder, 'uploads', 
'datasets', request.vars.dataset_id)

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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to