[Twisted-web] Passing data to render functions

Simon Pickles sipickles at googlemail.com
Thu May 15 15:29:31 EDT 2008


In the example below, I want to use a member of the class to process the
HTML render request. How can I arrange my code to allow access to class

# -----------------------------------------------------------
from nevow import loaders
from nevow import rend
from nevow import tags as T

import monitorBroker

class HttpServer(rend.Page):
    def __init__(self):
         def ServerInfo(self, ctx, data):
              self.broker.GetServerData()  # self refers to
WovenContext, not HttpServer, not happy!

         self.addSlash = True
         self.docFactory = loaders.stan( T.html [ T.head ( title =
"TestMonitor" ),
                                               T.body [ T.h1[ "Test
Monitor 0.1" ],
                                                        T.div[ "HUB
Server: ", ServerInfo]

         self.broker = monitorBroker.PBroker('', 7021)




More information about the Twisted-web mailing list