1.1 --- a/WebStack/Generic.py Sun Nov 05 23:12:14 2006 +0000
1.2 +++ b/WebStack/Generic.py Sun Nov 05 23:53:36 2006 +0000
1.3 @@ -671,22 +671,68 @@
1.4
1.5 """
1.6 Transform the given 'path' using the specified 'relative_path'. For
1.7 - example:
1.8 + example, a simple identifier replaces the last component from 'path':
1.9
1.10 trans.update_path("/parent/node", "other") -> "/parent/other"
1.11
1.12 + If the last component is empty, the effect is similar to an append
1.13 + operation:
1.14 +
1.15 trans.update_path("/parent/node/", "other") -> "/parent/node/other"
1.16
1.17 + Where 'relative_path' is empty, the result is 'path' with the last
1.18 + component erased (but still present):
1.19 +
1.20 + trans.update_path("/parent/node", "") -> "/parent/"
1.21 +
1.22 + trans.update_path("/parent/node/", "") -> "/parent/node/"
1.23 +
1.24 + Where 'relative_path' contains ".", the component is regarded as being
1.25 + empty:
1.26 +
1.27 + trans.update_path("/parent/node", "other/./more") -> "/parent/other/more"
1.28 +
1.29 + trans.update_path("/parent/node/", "other/./more") -> "/parent/node/other/more"
1.30 +
1.31 + However, at the start of 'relative_path', "." can remove one component:
1.32 +
1.33 + trans.update_path("/parent/node", ".") -> "/parent"
1.34 +
1.35 + trans.update_path("/parent/node/", ".") -> "/parent/node"
1.36 +
1.37 + Adding "/" immediately afterwards restores any removed "/":
1.38 +
1.39 + trans.update_path("/parent/node/", "./") -> "/parent/node/"
1.40 +
1.41 + trans.update_path("/parent/node", "./") -> "/parent/"
1.42 +
1.43 + Following components add to the effect of "./":
1.44 +
1.45 + trans.update_path("/parent/node", "./other/more") -> "/parent/other/more"
1.46 +
1.47 + trans.update_path("/parent/node/", "./other/more") -> "/parent/node/other/more"
1.48 +
1.49 + Where 'relative_path' contains "..", two components are removed from the
1.50 + resulting path:
1.51 +
1.52 + trans.update_path("/parent/node/", "..") -> "/parent"
1.53 +
1.54 + trans.update_path("/parent/node/", "../other") -> "/parent/other"
1.55 +
1.56 + trans.update_path("/parent/node", "..") -> "/"
1.57 +
1.58 trans.update_path("/parent/node", "../other") -> "/other"
1.59
1.60 - trans.update_path("/parent/node/", "../other") -> "/parent/other"
1.61 + Where fewer components exist than are to be removed, the path is reset:
1.62 +
1.63 + trans.update_path("/parent/node", "../..") -> "/"
1.64 +
1.65 + Subsequent components are applied to the reset path:
1.66
1.67 trans.update_path("/parent/node", "../../other") -> "/other"
1.68
1.69 trans.update_path("/parent/node/", "../../other") -> "/other"
1.70
1.71 - trans.update_path("/parent/node", "..") -> "/"
1.72 -
1.73 Where 'relative_path' begins with "/", the 'path' is reset to "/" and
1.74 the components of the 'relative_path' are then applied to that new path:
1.75
1.76 @@ -696,13 +742,6 @@
1.77 result:
1.78
1.79 trans.update_path("/parent/node", "other/") -> "/parent/other/"
1.80 -
1.81 - Where 'relative_path' is empty, the result is 'path' minus the last
1.82 - component, unless it was an empty component:
1.83 -
1.84 - trans.update_path("/parent/node", "") -> "/parent/"
1.85 -
1.86 - trans.update_path("/parent/node/", "") -> "/parent/node/"
1.87 """
1.88
1.89 rparts = relative_path.split("/")