On 23 Feb., 13:49, Remi Jolin - SysGroup <[email protected]>
wrote:
> 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 thislink:
> >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")]
[wrong! was this:]
name_grid = [("Edit", makeEditLink(id)), ("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)

Yes, that's the solution!

Even though I do not really understand it:

- why "makeEditLink" without argument as replacement of (the string)
"id"?
- but why defined with argument?
- and why the class as argument?

Thanks a lot!

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

Reply via email to