what do you have in row.pdf_path ?
I assumed it was a Field('...', 'upload') but instead it seems that carries 
the whole link that is pregenerated and stored in the db.... in that case, 
just use _href=row.pdf_path ....

Il giorno venerdì 4 ottobre 2013 12:51:16 UTC+2, Gael Princivalle ha 
scritto:
>
> Hi Niphlod.
>
> Thanks for your answer, I've resolved my first problem, now with 
> args=row.pdf_path web2py read what there's inside the field. Great.
> But I'm still don'tunderstand how I can have an obsolute path.
> I've read that host=True can resolve it, but it don't.
>
> In the A helper:
> links = [lambda row: A('Catalogue', host=True, _href=URL('default', 
> 'download', args=row.pdf_path))]
> Result > http://..../my_application/default/download/http://
> www.example.com/mycatalogue.pdf
>
> In the URL helper:
> links = [lambda row: A('Catalogue', _href=URL('default', 'download', 
> host=True, args=row.pdf_path))]
> Same result.
>
> Can you help me ?
>
>
> Il giorno giovedì 3 ottobre 2013 21:18:12 UTC+2, Niphlod ha scritto:
>>
>> uhm: seems that you didn't quite get how lambda works.....
>>
>> lambda row : something(row)
>>
>> equals to 
>>
>> def something(row):
>>       return 'a'
>>
>> lambda is used just to "inline" a small snippet of code.
>>
>> In your case, you need to generate the link from the field pdf_path, but 
>> you need to take the pdf_path from the row you're passing to the 
>> function.....
>>
>> def generate_link(row):
>>       return A('whatever', _href=URL('default', 'download', 
>> args=row.pdf_path))
>>
>> that, "transformed" to the "lambda format" is
>>
>> lambda row : A('whatever', _href=URL('default', 'download', 
>> args=row.pdf_path))
>>
>> As for having the URL absolute instead of relative, use the host 
>> parameter of the A helper.
>>
>> On Thursday, October 3, 2013 5:32:20 PM UTC+2, Gael Princivalle wrote:
>>>
>>> Hi.
>>>
>>> In a table I have that:
>>>     db.define_table('products',
>>>         Field('code', unique=True),
>>>         Field('description'),
>>>         Field('brand'),
>>>         Field('pdf_path'))
>>>
>>> I want to have a sqlform.grid that gone have all links to pdf_path 
>>> field. These are absolute links like "
>>> http://www.example.com/mycatalogue.pdf";
>>>
>>> Here is my controller:
>>> def products_listing():
>>>     links = [lambda row: A('pdf', _href=db.products.pdf_path)]
>>>     grid = SQLFORM.grid(db.products, orderby=db.products.code, 
>>> links=links,links_in_grid=True)
>>>     return dict(grid=grid)
>>>
>>> I have two problems, path is relative because it begin at my website 
>>> http://..../my_application/default
>>> And the products.pdf_path field is not considered like a filed, but like 
>>> a string.
>>>
>>> The result is:  http://..../my_application/default/products.pdf_path
>>>
>>> I've tried also to play with the URL helper but without result.
>>>
>>> An idea ?
>>>
>>> Thanks.
>>>
>>

-- 
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