URL generation for resources
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. 157 def putChild(self, path, child): 158 """Register a static child. 159 160 You almost certainly don't want '/' in your path. If you 161 intended to have the root of a folder, e.g. /foo/, you want 162 path to be ''. 163 """ 164 self.children[path] = child 165 child.server = self.server If putChild were extended a little bit, it could set some info on the child whenever it's "placed" into the tree, i.e. 165+ child.parent = self 165+ child.path = path This would make possible a "getFullPath" method that iterates up the tree to the root, concatenating the parts with "/". Does anyone see the value of this, if I were to subject such a patch? Obviously this is only relevant for statically-routed resources.
participants (1)
-
John Porter Simons