Commit 654bae09 authored by Chris McDonough's avatar Chris McDonough

App/FindHomes.py now computes the "real" path for SOFTWARE_HOME and

        INSTANCE_HOME, resolving any symlinks in any element within paths
        passed in via the INSTANCE_HOME or SOFTWARE_HOME envvars.  Paths that
        are computed by "dead reckoning" from os.getcwd and module paths are
        also "realpathed".  So for instance, if you use '/home/chrism/Instance'
        as your INSTANCE_HOME, and '/home/chrism' is a symlink to
        '/other/home/chrism', your INSTANCE_HOME will be computed as
        '/other/home/chrism/Instance'.  This is necessary to avoid
        weirdnesses while using "dead reckoning" from INSTANCE_HOME and
        SOFTWARE_HOME in other parts of the code.  POSIX systems only.
parent 3f4cd721
...@@ -57,7 +57,18 @@ Zope Changes ...@@ -57,7 +57,18 @@ Zope Changes
- Collector #304: several catalog optimisations - Collector #304: several catalog optimisations
Bugs: Bugs:
- App/FindHomes.py now computes the "real" path for SOFTWARE_HOME and
INSTANCE_HOME, resolving any symlinks in any element within paths
passed in via the INSTANCE_HOME or SOFTWARE_HOME envvars. Paths that
are computed by "dead reckoning" from os.getcwd and module paths are
also "realpathed". So for instance, if you use '/home/chrism/Instance'
as your INSTANCE_HOME, and '/home/chrism' is a symlink to
'/other/home/chrism', your INSTANCE_HOME will be computed as
'/other/home/chrism/Instance'. This is necessary to avoid
weirdnesses while using "dead reckoning" from INSTANCE_HOME and
SOFTWARE_HOME in other parts of the code. POSIX systems only.
- Fixed PropertyManager/PropertySheets so that you can safely add a - Fixed PropertyManager/PropertySheets so that you can safely add a
property named 'ids' without breaking your properties page. property named 'ids' without breaking your properties page.
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"""Commonly used utility functions.""" """Commonly used utility functions."""
__version__='$Revision: 1.11 $'[11:-2] __version__='$Revision: 1.12 $'[11:-2]
import sys, os, time import sys, os, time
...@@ -109,3 +109,26 @@ def attrget(o,name,default): ...@@ -109,3 +109,26 @@ def attrget(o,name,default):
def Dictionary(**kw): return kw # Sorry Guido def Dictionary(**kw): return kw # Sorry Guido
def realpath(p):
""" Computes the 'real' path of a file or directory devoid of
any symlink in any element of the path """
p = os.path.abspath(p)
if os.name == 'posix':
path_list = p.split(os.sep)
orig_len = len(path_list)
changed = 0
i = 1
while not changed and i < orig_len:
head = path_list[:i]
tail = path_list[i:]
head_s = os.sep.join(head)
tail_s = os.sep.join(tail)
if os.path.islink(head_s):
head_s = os.readlink(head_s)
path_list = head_s.split(os.sep)
path_list.extend(tail)
p = os.sep.join(path_list)
p = realpath(p)
changed = 1
i = i + 1
return p
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
"""Commonly used utility functions.""" """Commonly used utility functions."""
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
import os, sys, Products import os, sys, Products
from Common import package_home from Common import package_home, realpath
path_join = os.path.join path_join = os.path.join
path_split = os.path.split path_split = os.path.split
...@@ -31,10 +31,12 @@ except: ...@@ -31,10 +31,12 @@ except:
if path_split(home)[1]=='..': if path_split(home)[1]=='..':
home=path_split(path_split(home)[0])[0] home=path_split(path_split(home)[0])[0]
home=realpath(home)
sys.modules['__builtin__'].SOFTWARE_HOME=SOFTWARE_HOME=home sys.modules['__builtin__'].SOFTWARE_HOME=SOFTWARE_HOME=home
try: try:
chome=os.environ['INSTANCE_HOME'] chome=os.environ['INSTANCE_HOME']
chome = realpath(chome)
except: except:
chome=home chome=home
d,e=path_split(chome) d,e=path_split(chome)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment