[Twisted-web] Re: NevowSite and renderString (was: really
andrew at ellerton.net
Wed Apr 7 14:28:57 MDT 2004
> Have you tried using NevowSite, but giving it one of your custom
> resources instead of a nevow.rend.Page instance? I'm not sure whether
> that will work or not, but I don't see why it shouldn't. NevowSite is
> just a subclass of t.w.server.Site, which you need anyways.
That works nicely, thanks :)
I'll keep experimenting there and tinker with things to get a better understanding of how the parts work together.
In the meantime, I'm having trouble with lists now - in particular, I want to display a list and have each item be a link. I looked at the Nevow calendar example but I can't follow it.
In my page class I have this (excerpt):
def data_names(self, context, data):
# this is a list of strings
def getURLForName( self, name ):
# a crappy demo of how I can parameterise getting the URL
# for a given name
return "/data/%s" % name
def render_link(self, context, data):
# would it be better to do something like:
# return T.a(href=url)[title],
name = ??
url = self.getURLForName( name )
return "<a href='%s'>%s</a>" % ( url, title )
I know this code isn't great, but the thing I'm stuck on right now is how do I get the name argument - from the data parameter?
Oh, and I probably shouldn't be calling it render_link... sorry guys, I get lost with Nevow a bit! :)
The html fragment I'm using is:
<p>This is called <span nevow:data="title" nevow:render="string" /></p>
<p>This is a list of stuff:<br/>
<ol nevow:data="names" nevow:render="sequence">
<li nevow:pattern="item"><span nevow:render="string" /></li>
The title span is working really well - and many thanks here go to Alex Levy!
thanks for any help on the above
More information about the Twisted-web