Hi,
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 members?
# ----------------------------------------------------------- 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('127.0.0.1', 7021)
#-----------------
Thanks
Simon
Sorry, I've just demonstrated a hole in my python.
If I change the function to this then it will work since I am not overwriting the self, and the context is in the right place!
def ServerInfo(ctx): self.broker.GetServerData(serverData.HUB_SERVER)
Guess you realise-something-very-obvious everyday!