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