[Twisted-web] Nevow upgrading trouble 2.0 ->4.1

Yun Mao maoy+twisted at cis.upenn.edu
Sat May 28 21:56:09 MDT 2005

This is part of it (locateChild omitted). Thanks.

class SessionRoot(rend.Page):
     docFactory = loaders.htmlfile(
         templateDir = os.path.join(getAbsResourcePath(),'template'),
         template ='session.html')
     child_css = 
     child_images = 

     viewall = False # view all sessions or not

     def data_nAllSessions(self, context, data):
         return len(smanager.socks.items())
     def data_nActiveSessions(self, context, data):
         count = 0
         for k,v in smanager.socks.items():
             if v.state!="ended": count += 1
         return count
     def data_haSelection(self, context, data):
         return smanager.ha_selection
     def data_globalSSLOption(self, context, data):
         return "SSL(%s)" % (smanager.smartSSL)

     def data_session(self, context, data):
         #print inevow.IRequest(context).args

         result = []
         for k,v in smanager.socks.items():
             if not self.viewall:
                 if v.state=="ended": continue
             x = {}
             x['value'] = v
             x['myID'] = v.myID
             x['sessionID'] = v.getSessionID()
             x['remotehost'] = "%s:%s" % (v.realserver, v.realport)
             x['homeagent'] = v.getHomeAgent()

             x['status'] = v.getSessionState()
             x['message'] = v.infolog.getLatestInfo()
             x['error'] = v.errinfo
         return result

     def render_mymapping(self, context, data):
         mylog(3, 'hey!, in mymapping %s'% (str(data)))
         for k, v in data.items():
             context.fillSlots(k, v)
         return context.tag

     def render_status(self, context, data):
         mylog(3, 'hey!, in status %s'% (data['status']))

         tag = context.tag.clear()
         if data['value'].state!="ended":
             tag.attributes['href'] = "?adapt=%d" % data['myID']
             tag.attributes['title']="Click to do adaptation for session 
%d" % data['myID']

         return tag

     def render_message(self, context, data):
         tag = context.tag.clear()
         tag.attributes['href'] = 
         tag.attributes['title'] = "Click to see the detailed messages"
         msg = data['message']
         if len(msg)>43:
             msg = msg[:40]+"..."
         return tag

     def render_SSLOption(self, context, data):
         tag = context.tag.clear()
         msg = data['value'].isSSLEnabled() and "Enabled" or "Disabled"
         if data['value'].state!="ended":
             tag.attributes['href'] = "?switchSSL=%d" % data['myID']
             tag.attributes['title']="Click to %s SSL" %\
                                      (data['value'].isSSLEnabled() and 
"disable" or "enable")
         return tag

On Sat, 28 May 2005, Dave Cook wrote:

> What does your Page class look like?
> Dave Cook

More information about the Twisted-web mailing list