[Twisted-web] best way to find my place in the tree
Lee Harr
missive at hotmail.com
Sat Jul 3 12:42:34 MDT 2004
Playing around with examples/tree.tac, I came up with this:
Index: tree.tac
===================================================================
--- tree.tac (revision 375)
+++ tree.tac (working copy)
@@ -38,7 +38,7 @@
<span nevow:render="childDel"/>
</li>
</ol>
-<a href="..">Up</a>
+<a nevow:render="notRoot" href="..">Up</a>
</body>
</html>
""")
@@ -65,10 +65,17 @@
T.input(type="hidden", name="name", value=name),
T.input(type="submit", value="Delete")]
return ret
-
+ def render_notRoot(self, context, data):
+ request = context.locate(inevow.IRequest)
+ if request.path.find('subtree_') > 0:
+ return T.a(href='..')['Up']
+ else:
+ return 'Root of tree'
+
+
compy.registerAdapter(TreeRenderer, Tree, inevow.IResource)
t = Tree('base', 'base')
application = service.Application("tree")
s = strports.service('8080', appserver.NevowSite(t))
====
which works as long as the subnodes are called 'subtree_*'
Is this the way you would do this? Something more general?
(maybe count '/' or something better) Something completely
different ...?
Thanks for your time.
_________________________________________________________________
MSN 8 with e-mail virus protection service: 2 months FREE*
http://join.msn.com/?page=features/virus
More information about the Twisted-web
mailing list