[Twisted-web] nested nevow:data
    James Y Knight 
    foom at fuhm.net
       
    Mon May  9 08:23:32 MDT 2005
    
    
  
On May 8, 2005, at 4:18 AM, Little wrote:
> How can i use nested nevow:data construction?
>
The next data is always looked up in the current data. At the top  
level, the current data is the page you're rendering, with its data_  
methods. As you saw, when you nest one inside another, the current  
data when looking up the inner data is the outer data, rather than  
the page.
A workaround is to use a renderer instead of a data directive. I  
believe something like this should work:
def render_getyeardata(self, ctx, data):
   d = runQuery("select * from ... where year="%s")
   def rememberIt(result):
     ctx.remember(result, inevow.IData)
     return ctx.tag
   d.addCallback(rememberIt)
   return d
Then in your page,
<div n:data="years" n:render="years">
  <div n:pattern="year">
    <table>
    <n:invisible render="getyeardata"><div n:render="year">
etc.
The real solution is to patch nevow to allow for some sort of data  
navigation, like data="/year", where the leading slash means "from  
the page". Someone was working on that, but I don't know where it  
went. It'd be good to have that capability built-in.
James
    
    
More information about the Twisted-web
mailing list