[Twisted-web] Nevow Tables

Simon Pickles sipickles at googlemail.com
Fri May 16 14:40:07 EDT 2008


hmm,

Well, I've met stan, and that is all good for handy supplied tuples, but 
I am having trouble integrating this with my lists from remote PBs.

I've a little Nevow monitor app which is requesting data from a server 
and generating HTML from it, in theory.

The comms are fine, but building a table of the supplied data is eluding me!

Please get your red pen out:

#-----------------------
#import stuff

class HttpServer(rend.Page):
    def __init__(self):
        self.broker = monitorBroker.PBroker("monitor", '127.0.0.1', 7021)
        self.docFactory = loaders.xmlfile('main.html') # includes <div 
nevow:render="serverData" />
       
    def render_serverData(self, ctx):
        def useResult(data):
            return T.table(render=T.directive('sequence'))[
                T.tr(pattern='header')[ T.th[ 'sID' ], T.th[ 'host' ] ],
                T.tr(pattern='item', render=T.directive('row')),
                T.tr(pattern='item', render=T.directive('row'))
            ]
   
        def render_row(self, ctx, rowData):
            return ctx.tag[ T.td[ rowData[0] ], T.td[ rowData[1] ] ]    
                
               
        d = self.broker.DoRemoteCallFromMonitor(serverData.HUB_ZONEDATA)
        d.addCallback(useResult)
        return d
#---------------------

The remote PB supplies data like this:
(((0,0), "alpha"), ((0,1), "beta", ((1,0), "alpha"), ((1,1), "alpha"))
representing the rows and cols of the table.

Can anyone help beat my code into shape?

Thanks


Si



More information about the Twisted-web mailing list