le 23.02.2009 13:41 ruko a écrit:
>
>   
> I tried this:
>
> (1)
> --------------------------------------------
> def makeEditLink(id):
>     return Markup("""<a href="/edit/%s" >Edit</a>""" % id)
>
> name_grid = [("Edit", makeEditLink), ("Name", "name"), ("Birth",
> "birth")]
>
> I got this link:
> http://10.172.1.113:8090/edit/<namecollection.model.name.Names object
> at 0x27ff490>
> --------------------------------------------
>
> (2)
> --------------------------------------------
> def makeEditLink(id):
>     return Markup("""<a href="/edit/%s" >Edit</a>""" % id.link)
>
> name_grid = [("Edit", makeEditLink), ("Name", "name"), ("Birth",
> "birth")]
>
> I got this error (obviously):
> AttributeError: 'Names' object has no attribute 'link'
> --------------------------------------------
>
> (3)
> --------------------------------------------
> def makeEditLink(id):
>     return Markup("""<a href="/edit/%s" >Edit</a>""" % id)
>
> name_grid = [("Edit", makeEditLink), ("Name", "name"), ("Birth",
> "birth")]
>
> I got this error:
> AttributeError: 'Names' object has no attribute '<a href="/edit/<built-
> in function id>" >Edit</a>'
> --------------------------------------------
>
>   
I can't see the difference between (1) and (3) but I think the problem 
is not here...
Your makeEditLink function will get a Names instance as parameter. If 
the primary key of this "class" is called id, your function should be

def makeEditLink(aName):
    return Markup("""<a href="/edit/%s" >Edit</a>""" % aName.id)




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to turbogears@googlegroups.com
To unsubscribe from this group, send email to 
turbogears+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to