[Zope-Checkins] CVS: Zope3/lib/python/Zope/TAL - setpath.py:1.7
Fred L. Drake, Jr.
fdrake@acm.org
Wed, 12 Jun 2002 10:08:07 -0400
Update of /cvs-repository/Zope3/lib/python/Zope/TAL
In directory cvs.zope.org:/tmp/cvs-serv19936
Modified Files:
setpath.py
Log Message:
Merge from the fdrake-tal-i18n-branch:
Barry's setpath changes.
=== Zope3/lib/python/Zope/TAL/setpath.py 1.6 => 1.7 ===
##############################################################################
"""
-Read a module search path from .path.
+Read a module search path from .path file.
+
+If .path file isn't found in the directory of the setpath.py module, then try
+to import ZODB. If that succeeds, we assume the path is already set up
+correctly. If that import fails, an IOError is raised.
"""
import os
import sys
@@ -22,14 +26,19 @@
try:
f = open(path)
except IOError:
- raise IOError, "Please edit .path to point to <Zope2/lib/python>"
+ try:
+ # If we can import ZODB, our sys.path is set up well enough already
+ import ZODB
+ except ImportError:
+ raise IOError("Can't find ZODB package. Please edit %s to point to "
+ "your Zope's lib/python directory" % path)
else:
for line in f.readlines():
line = line.strip()
if line and line[0] != '#':
- for dir in string.split(line, os.pathsep):
+ for dir in line.split(os.pathsep):
dir = os.path.expanduser(os.path.expandvars(dir))
if dir not in sys.path:
sys.path.append(dir)
-
-import ZODB # Must import this first to initialize Persistence properly
+ # Must import this first to initialize Persistence properly
+ import ZODB