Nevow upgrading trouble 2.0 ->4.1

The following template doesn't work any more (worked with 2.0). In particular, my own render_status() and render_message() don't get called any more. This was my first and only nevow program. So, my relevant knowledge is quite limited. Is there any major changes between those versions? Any suggestions will be appreciated!! Yun =====begin HTML template======== <table border="0" cellspacing="1" width="90%"> <tr> <td class="grey" width="5%">ID</td> <!-- <td class="grey" align="center">sessionID</td> --> <td class="grey" align="center">remote host</td> <td class="grey" align="center">home agent</td> <td class="grey" align="center">status</td> <td class="grey" align="center">messages</td> <td class="grey" align="center">last error</td> <td class="grey" align="center" width="10%"> <a nevow:data="globalSSLOption" href="?switchSSL=-1" nevow:render="string" title="Click to switch smart SSL option">SSL</a></td> </tr> <span nevow:data="session" nevow:render="sequence"> <tr nevow:pattern="item" nevow:render="mymapping"> <td class="blue"><nevow:slot name="myID" /></td> <td class="blue"><nevow:slot name="remotehost" /></td> <td class="blue"><nevow:slot name="homeagent" /></td> <td class="blue" align="center"><a nevow:pattern="status" nevow:render="status">running</a></td> <td class="blue"><a nevow:pattern="messageItem" nevow:render="message" href="?"> message</a> </td> <td class="blue"><nevow:slot name="error" /></td> <td class="blue" align="center"><a nevow:pattern="SSLOption" nevow:render="SSLOption">Disabled</a></td> </tr> </span> </table> ======END html template=========

On 5/28/05, Yun Mao <maoy+twisted@cis.upenn.edu> wrote:
The following template doesn't work any more (worked with 2.0). In particular, my own render_status() and render_message() don't get called any more. This was my first and only nevow program. So, my relevant knowledge is quite limited. Is there any major changes between those versions? Any suggestions will be appreciated!!
What does your Page class look like? Dave Cook

This is part of it (locateChild omitted). Thanks. Yun ============== class SessionRoot(rend.Page): docFactory = loaders.htmlfile( templateDir = os.path.join(getAbsResourcePath(),'template'), template ='session.html') child_css = static.File(os.path.join(getAbsResourcePath(),'template/css')) child_images = static.File(os.path.join(getAbsResourcePath(),'template/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 result.append(x) 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'] tag.children.append(data['status']) return tag def render_message(self, context, data): tag = context.tag.clear() tag.attributes['href'] = here.child('msg').child(str(data['myID'])) tag.attributes['title'] = "Click to see the detailed messages" msg = data['message'] if len(msg)>43: msg = msg[:40]+"..." tag.children.append(msg) 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") tag.children.append(msg) return tag ========== On Sat, 28 May 2005, Dave Cook wrote:
What does your Page class look like?
Dave Cook

Yun Mao wrote:
This is part of it (locateChild omitted). Thanks.
Yun ============== class SessionRoot(rend.Page): docFactory = loaders.htmlfile(
DO NOT use htmlfile. use xmlfile. if you don't have an xhtml template try with tidy and use the xhtml result. -- Valentino Volonghi aka Dialtone Now Running MacOSX 10.4.1 Blog: http://vvolonghi.blogspot.com http://weever.berlios.de

On 5/28/05, Yun Mao <maoy+twisted@cis.upenn.edu> wrote:
nevow:render="status">running</a></td> <td class="blue"><a nevow:pattern="messageItem" nevow:render="message"
I don't know if having both a pattern and a render method defined causes a problem, but since you don't use this as a pattern, I'd just leave that out and only include nevow:render="message". Dave Cook

Wonderful, problem solved! Thanks!! Yun BTW1, I just realized that I messed up with the versions -- they are 0.2 and 0.4.1 respectively. But it seems to have caused no confusion yet. :) BTW2, is it a "feature" of 0.2 or a bug of 0.4.1? On Sat, 28 May 2005, Dave Cook wrote:
On 5/28/05, Yun Mao <maoy+twisted@cis.upenn.edu> wrote:
nevow:render="status">running</a></td> <td class="blue"><a nevow:pattern="messageItem" nevow:render="message"
I don't know if having both a pattern and a render method defined causes a problem, but since you don't use this as a pattern, I'd just leave that out and only include nevow:render="message".
Dave Cook
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web

Yun Mao wrote:
Wonderful, problem solved! Thanks!!
Yun
BTW1, I just realized that I messed up with the versions -- they are 0.2 and 0.4.1 respectively. But it seems to have caused no confusion yet. :)
BTW2, is it a "feature" of 0.2 or a bug of 0.4.1?
It's ok to have a pattern and a render attribute on an element - it's something you'll use when rendering sequence items quite often, i.e. <ul nevow:data="numbers" nevow:render="sequence"> <li nevow:pattern="item" nevow:render="data">NUMBER GOES HERE</li> </ul> The difference between 0.2 and 0.4.1 (I think it changed in 0.3 actually) is that patterned elements are automatically removed from the page; unless they're found and used by a renderer, of course. Cheers, Matt
On Sat, 28 May 2005, Dave Cook wrote:
On 5/28/05, Yun Mao <maoy+twisted@cis.upenn.edu> wrote:
nevow:render="status">running</a></td> <td class="blue"><a nevow:pattern="messageItem" nevow:render="message"
I don't know if having both a pattern and a render method defined causes a problem, but since you don't use this as a pattern, I'd just leave that out and only include nevow:render="message".
Dave Cook
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
_______________________________________________ Twisted-web mailing list Twisted-web@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
-- __ / \__ Matt Goodall, Pollenation Internet Ltd \__/ \ w: http://www.pollenation.net __/ \__/ e: matt@pollenation.net / \__/ \ t: +44 (0)113 2252500 \__/ \__/ / \ Any views expressed are my own and do not necessarily \__/ reflect the views of my employer.
participants (4)
-
Dave Cook
-
Matt Goodall
-
Valentino Volonghi aka Dialtone
-
Yun Mao