Manlio Perillo ha scritto: > Hi. > > I need to set/unset an attribute (checked) on a <input type="checkbox"> > element (in a xml template). > > I'm using IQ.onePattern, but the problem is that the node is "removed" > from the "stan context". > > Now I'm doing this from my render function: >
Sorry, the example was wrong. Here is my template: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:n="http://nevow.com/ns/nevow/0.1" lang="en" xml:lang="en"> <head> <title>Test</title> </head> <body> <form action="update" method="post"> <table> <caption /> <thead /> <tbody n:render="sequence" n:data="list"> <tr n:pattern="item" n:render="item"> <td><n:slot name="x" /></td> <td> <input n:pattern="checked" type="checkbox"> <n:attr name="name"><n:slot name="x" /></n:attr> </input> </td> </tr> </tbody> </table> <p> <input class="button" type="submit" value="update" /> <input class="button" type="reset" value="reset" /> </p> </form> </body> </html> And my code: from nevow import rend, loaders, inevow, static, url, tags class Page(rend.Page): docFactory = loaders.xmlfile("node.xhtml") def data_list(self, ctx, data): return [1, 2, 3] def render_item(self, ctx, data): ctx.fillSlots("x", data) checked = ctx.tag.onePattern("checked") if data > 1 : checked.attributes["checked"] = "true" ctx.tag.children[-1] = checked return ctx.tag from twisted.cred import portal, checkers, credentials from twisted.application import service, strports from nevow import appserver application = service.Application("test") site = appserver.NevowSite(Page()) addr = "tcp:80:interface=127.0.0.1" strports.service(addr, site).setServiceParent(application) The code now works, but this is an hack (because I have to know where to put the node). Is there a better solution? Thanks and regards Manlio Perillo _______________________________________________ Twisted-web mailing list [email protected] http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
