[Zope-dev] explicit sys.path manipulation in test.py causing problems

Rob Miller ra at burningman.com
Wed Sep 10 14:29:46 EDT 2008


hi all,

in Zope's testrunner, the SOFTWARE_HOME is explicitly added to the front of
the python package lookup path, like so:

sys.path.insert(0, shome)

this doesn't happen in the same manner when you're actually starting a Zope
server.  as a result, the test runner will not work in certain environments
where Zope itself is purring happily along.

specifically, i've got a setup where Zope 2.10 is installed into a virtualenv
using the traditional Zope install mechanisms.  i want to use ZODB BLOB
storage, however, so i've got ZODB 3.8 eggs installed.  setuptools gives eggs
precedence over non-egg packages, so this works well, except when using
test.py, where the explicit insertion of SOFTWARE_HOME at the very
beginning of sys.path trumps the egg installation.

i'd like to put a check in there so that SOFTWARE_HOME is only added to the
package lookup if the Zope2 package isn't already available:

try:
     import Zope2
except ImportError:
     sys.path.insert(0, shome)

in other words, if the environment is already set up, don't mess with it.

anyone have a problem w/ me making this change on trunk and the 2.10 and 2.11 
branches?

-r



More information about the Zope-Dev mailing list