Michael Pearce schrieb:
> 
> 
> On Sat, Jan 31, 2009 at 7:12 AM, Jim Steil <[email protected] 
> <mailto:[email protected]>> wrote:
> 
> 
>     Michael Pearce wrote:
>      > Not sure if anyone saw my previous email. I haven't seen a response
>      > yet so I'll try one more attempt (as getting desparate now). My
>      > application is displaying a DataGrid widget via a Genshi template. I
>      > would like the data in one column to be displayed as a href link so
>      > that users can click on any of the records in order to display an
>     edit
>      > screen for that particular record. Now, one of the Turbogears
>      > tutorials shows an example of this using Kid templates. This method
>      > uses the Kid Element object which is passed to the DataGrid on
>      > creation. I have no problem getting the tutorial example to work,
>      > however I'm not sure what needs to be passed to the DataGrid when
>      > using Genshi. I have searched the Geshi documentation but cannot find
>      > a relevant example to help solve my problem. Any assistance would be
>      > greatly appreciated.
>      >
>      > Thanks,
>      > Michael
>      >
>      >
>      >
>      > >
>     Can you post a sample of your code?
> 
>  
>  
> Here is a sample based on an example on the genshi website:
>  
> from genshi.builder import Element, tag
>  
> def get_link(gridVal)
>     link = tag.a(gridVal, href="target")
>     return link
>  
> the function then gets called when I create the datagrid.
>  
> Another example from genshi that I tried is:
>  
> def get_link(gridVal):
>     link = Element('a')(gridVal, href="target")
>     return link
>  
> Both of these return the error:
>  
> AttributeError: 'Element' object has no attribute 'text'
>  
> This is strange as I'm not even using a 'text' attribute.

I never saw the above way to create things, however I think this should 
work:


from genshi import Markup

def get_link(item):
     return Markup("""<a href="%s" >Link</a>""" % item.link)

Diez

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