I need to, given an IResource object that's in a site's resource tree, get its full URL (in order to generate links to it). Looking in twisted/web/resource.py, it appears that URL traversal is strictly one-way, with resources having no idea what their path component is, nor what their parent resource is.<br>
<br>157 def putChild(self, path, child):<br>158 """Register a static child.<br>159 <br>160 You almost certainly don't want '/' in your path. If you<br>161 intended to have the root of a folder, e.g. /foo/, you want<br>
162 path to be ''.<br>163 """<br>164 self.children[path] = child<br>165 child.server = self.server<br><br>If putChild were extended a little bit, it could set some info on the child whenever it's "placed" into the tree, i.e.<br>
<br>165+ child.parent = self<br>165+ child.path = path<br><br>This would make possible a "getFullPath" method that iterates up the tree to the root, concatenating the parts with "/".<br><br>
Does anyone see the value of this, if I were to subject such a patch? Obviously this is only relevant for statically-routed resources.<br><br>